| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
UnliftIO.AutoUpdate.Event
Synopsis
- mkAutoUpdate :: MonadUnliftIO m => UpdateSettings m a -> m (m a)
- mkAutoUpdateWithModify :: MonadUnliftIO m => UpdateSettings m a -> (a -> m a) -> m (m a)
- data UpdateState m a = UpdateState {
- usUpdateAction_ :: a -> m a
- usLastResult_ :: IORef a
- usIntervalMicro_ :: Int
- usTimeHasCome_ :: TVar Bool
- usDeleteTimeout_ :: IORef (m ())
- mkClosableAutoUpdate :: MonadUnliftIO m => UpdateSettings m a -> m (m a, m ())
- mkClosableAutoUpdate' :: MonadUnliftIO m => UpdateSettings m a -> m (m a, m (), UpdateState m a)
Creation
mkAutoUpdate :: MonadUnliftIO m => UpdateSettings m a -> m (m a) Source #
Generate an action which will either read from an automatically updated value, or run the update action in the current thread.
Since: 0.1.0
mkAutoUpdateWithModify :: MonadUnliftIO m => UpdateSettings m a -> (a -> m a) -> m (m a) Source #
Generate an action which will either read from an automatically updated value, or run the update action in the current thread if the first time or the provided modify action after that.
Since: 0.1.0
Internal
data UpdateState m a Source #
Constructors
| UpdateState | |
Fields
| |
mkClosableAutoUpdate :: MonadUnliftIO m => UpdateSettings m a -> m (m a, m ()) Source #
>>>iref <- newIORef (0 :: Int)>>>action = modifyIORef iref (+ 1) >> readIORef iref>>>(getValue, closeState) <- mkClosableAutoUpdate $ defaultUpdateSettings { updateFreq = 200_000, updateAction = action }>>>getValue1>>>threadDelay 100_000 >> getValue1>>>threadDelay 200_000 >> getValue2>>>closeState
mkClosableAutoUpdate' :: MonadUnliftIO m => UpdateSettings m a -> m (m a, m (), UpdateState m a) Source #
provide UpdateState for debugging