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

Replace Updateable with Settable class

parent d34bd2d7
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ module Qd.Observable (
subscribe',
SubscriptionHandle(..),
RegistrationHandle(..),
Settable(..),
Disposable(..),
ObservableCallback,
ObservableState,
......@@ -72,6 +73,10 @@ instance Observable v o => Observable v (IO o) where
subscribe observable callback
class Settable v a where
setValue :: a -> v -> IO ()
-- | Existential quantification wrapper for the Observable type class.
data SomeObservable v = forall o. Observable v o => SomeObservable o
instance Observable v (SomeObservable v) where
......@@ -105,6 +110,10 @@ instance Observable v (BasicObservable v) where
unsubscribe' :: Unique -> IO ()
unsubscribe' key = modifyMVar_ mvar $ \(state, subscribers) -> return (state, HM.delete key subscribers)
instance Settable v (BasicObservable v) where
setValue basicObservable = setBasicObservable basicObservable . Just
createBasicObservable :: Maybe v -> IO (BasicObservable v)
createBasicObservable defaultValue = do
BasicObservable <$> newMVar (defaultValue, HM.empty)
......
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