reflex-dom-contrib-0.4.1: A playground for experimenting with infrastructure and common code for reflex applications

Safe HaskellNone
LanguageHaskell2010

Reflex.Dom.Contrib.Pagination

Synopsis

Documentation

prResults :: forall a a. Lens (PaginationResults a) (PaginationResults a) [a] [a] Source

prOffset :: forall a. Lens' (PaginationResults a) Word64 Source

pvValue :: forall a a. Lens (CacheVal a) (CacheVal a) a a Source

pvShouldStore :: forall a. Lens' (CacheVal a) Bool Source

pvQuery :: forall a. Lens' (CacheVal a) PaginationQuery Source

data PaginationQuery Source

General data structure needed for running queries with paginated results.

data PaginationResults a Source

Data structure wrapping results.

Instances

Eq a => Eq (PaginationResults a) Source 
Ord a => Ord (PaginationResults a) Source 
Read a => Read (PaginationResults a) Source 
Show a => Show (PaginationResults a) Source 
ToJSON a => ToJSON (PaginationResults a) Source 
FromJSON a => FromJSON (PaginationResults a) Source 

data CacheVal a Source

Along with the query results we also need to store the PaginationQuery structure that generated it as well as a flag indicating whether this data should be stored in the cache. This prevents results that are sub-searches of a previous search from overwriting the results of a more general query.

Constructors

CacheVal 

Instances

Eq a => Eq (CacheVal a) Source 
Ord a => Ord (CacheVal a) Source 
Show a => Show (CacheVal a) Source 

data PQParams Source

Constructors

PQParams 

Fields

pqpMaxCacheSize :: Int

The max number of queries to cache

pqpPruneAmount :: Int

The number of queries to discard when we reach the size limit

paginatedQuery Source

Arguments

:: (MonadWidget t m, Show k, Ord k, FromJSON a) 
=> PQParams 
-> (String -> a -> Bool) 
-> String 
-> Event t (Map String ByteString, PaginationInput k)

Param map and pagination structure. k is any additional information that you need to disambiguate multiple PaginationQuery entries.

-> m (Event t (Maybe (PaginationResults a))) 

Paginated querying with built-in search and results caching.

prune :: Ord k => Int -> PaginationCache k (PaginationResults v) -> PaginationCache k (PaginationResults v) Source

Prunes the PaginationCache of the oldest n entries. This is not the oldest (k,v) pairs. It is the oldest vs out of all the (k,[v]) pairs.

cachedQuery :: (MonadWidget t m, Show k, Ord k, FromJSON a) => (String -> a -> Bool) -> String -> PaginationCache k (PaginationResults a) -> (Map String ByteString, PaginationInput k) -> m (Event t (PaginationOutput k (PaginationResults a))) Source

Checks a cache and makes a request to the supplied URL if the cached data cannot be used to serve the results of the current requested query.

isSubSearch Source

Arguments

:: PaginationQuery 
-> CacheVal (PaginationResults a)

Cached query results

-> Bool 

Checks whether a previous cached search string is a substring of the current search string. In this case we don't need to requery the server.