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

Safe HaskellNone




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.




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

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

data PQParams Source




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


:: (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


:: 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.