auto-update-unliftio-0.1.0.0: auto-update unlifted to MonadUnliftIO
Safe HaskellSafe-Inferred
LanguageHaskell2010

UnliftIO.AutoUpdate.Event

Synopsis

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

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 }
>>> getValue
1
>>> threadDelay 100_000 >> getValue
1
>>> threadDelay 200_000 >> getValue
2
>>> closeState

mkClosableAutoUpdate' :: MonadUnliftIO m => UpdateSettings m a -> m (m a, m (), UpdateState m a) Source #

provide UpdateState for debugging