Skip to content
Snippets Groups Projects
Commit 04d5c60b authored by Jens Nolte's avatar Jens Nolte
Browse files

Implement constObservable

parent a37a5a90
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ module Qd.Observable (
joinObservableEither,
mergeObservable,
mergeObservable',
constObservable,
FnObservable(..),
) where
......@@ -249,6 +250,17 @@ instance Observable v (FnObservable v) where
}
newtype ConstObservable a = ConstObservable (Maybe a)
instance Observable a (ConstObservable a) where
getValue (ConstObservable x) = return x
subscribe (ConstObservable x) callback = do
callback (Current, x)
return $ SubscriptionHandle { unsubscribe = return () }
-- | Create an observable that contains a constant value.
constObservable :: Maybe a -> SomeObservable a
constObservable = SomeObservable . ConstObservable
-- TODO implement
_cacheObservable :: Observable v o => o -> SomeObservable v
_cacheObservable = SomeObservable
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment