Popularity
3.1
Stable
Activity
0.0
Stable
3
3
1

Monthly Downloads: 11
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Control     Async    

async-refresh alternatives and similar packages

Based on the "async" category.
Alternatively, view async-refresh alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of async-refresh or a related project?

Add another 'async' Package

README

async-refresh Hackage version Stackage version Build Status

About

This is Haskell library implementing the logic for refreshing of expiring data according to user-provided actions.

Usage

  • Create a new configuration using newAsyncRefreshConf, providing the action to be used for data refreshing.

  • Adjust the configuration using the asyncRefreshConfSet* functions, in particular using asyncRefreshConfSetCallback.

  • Use newAsyncRefresh to initiate a new thread managing the asynchronous refreshing.

Example

The following IO action produces a TVar which is updated every ten seconds to contain the current time (wrapped in an Either SomeException, because refreshing may fail).

periodicTimeUpdater :: IO (TVar (Either SomeException UTCTime))
periodicTimeUpdater = runStderrLoggingT $ do
  timeStore <- liftIO $ newTVarIO (Left (toException NotFound))
  let conf = newAsyncRefreshConf (RefreshResult <$> liftIO getCurrentTime <*> pure Nothing)
        & asyncRefreshConfSetLabel "CurrentTime updated every 10 seconds"
        & asyncRefreshConfSetDefaultInterval (10 * 10^3)
        & asyncRefreshConfSetCallback (liftIO . atomically . writeTVar timeStore . fmap refreshResult)
  _ <- newAsyncRefresh conf
  return timeStore