Safe Haskell | None |
---|---|
Language | Haskell2010 |
A collection of utilities to provide a way to create and run Deadpan apps.
This should be the only Deadpan module imported by users intending to use Deadpan as a library in order to write DDP applications.
- runBareClient :: Params -> DeadpanApp a -> IO a
- runConnectClient :: Params -> DeadpanApp a -> IO a
- runConnectClientVersion :: Params -> Version -> DeadpanApp a -> IO a
- runPingClient :: Params -> DeadpanApp a -> IO a
- runPingClientVersion :: Params -> Version -> DeadpanApp a -> IO a
- handlePings :: DeadpanApp GUID
- logEverything :: DeadpanApp (Chan String)
- logEverythingVia :: DeadpanApp (Chan String)
- collect :: DeadpanApp ()
- dataOver :: ([Text] -> EJsonValue -> EJsonValue -> EJsonValue) -> Callback
- dataAdded :: Callback
- dataChanged :: Callback
- dataRemoved :: Callback
- subscriptions :: Traversal' (AppState a) EJsonValue
- setServerID :: DeadpanApp ()
- putInBase :: Text -> EJsonValue -> DeadpanApp ()
- setSession :: DeadpanApp GUID
- getURI :: String -> Either Error Params
- type Error = String
- type Params = (Domain, Port, Path)
- liftIO :: MonadIO m => forall a. IO a -> m a
Documentation
>>>
import Control.Applicative
>>>
import Test.QuickCheck
runBareClient :: Params -> DeadpanApp a -> IO a Source
Run a DeadpanApp against a set of connection parameters
Only runs the app. Does not send connection request. Does not respond to ping!
runConnectClient :: Params -> DeadpanApp a -> IO a Source
Run a DeadpanApp after establishing a server conncetion
Does not respond to ping!
runConnectClientVersion :: Params -> Version -> DeadpanApp a -> IO a Source
runPingClient :: Params -> DeadpanApp a -> IO a Source
Run a DeadpanApp after registering a ping handler, then establishing a server conncetion.
runPingClientVersion :: Params -> Version -> DeadpanApp a -> IO a Source
Same as runPingClient above but allows specifying version
handlePings :: DeadpanApp GUID Source
Automatically respond to server pings
logEverything :: DeadpanApp (Chan String) Source
Log all incomming messages to STDOUT
Passes all messages through a Chan in order to not intermingle output lines.
Returns the chan so that it can be used by other sections of the app.
Alternatively just set LineBuffering on your output handle.
logEverythingVia :: DeadpanApp (Chan String) Source
A variant of log-everything returning a chan to recieve messages on instead of STDOUT.
collect :: DeadpanApp () Source
A client that responds to server collection messages.
Warning: this overwrites the "subscription-data" key of the collections field of the AppState.
dataOver :: ([Text] -> EJsonValue -> EJsonValue -> EJsonValue) -> Callback Source
An app to handle the addition of subscription data items...
For Example: {"collection":"lists","msg":"added","id":F73xFyAuKrqsb2J3m,"fields":{"incompleteCount":6,"name":"Favorite Scientists"}}
Not especially useful on its own. You would usually use collect
instead.
dataChanged :: Callback Source
An app to handle the modification of subscription data items...
For Example: {"collection":"lists","msg":"changed","id":TThFzYerrZaxmgjA7,"fields":{"name":"List Aasdf"}}
Not especially useful on its own. You would usually use collect
instead.
dataRemoved :: Callback Source
An app to handle the removal of subscription data items...
For Example: {"collection":"lists","msg":"removed","id":By8CtgWGvbZfJPFsd}
Not especially useful on its own. You would usually use collect
instead.
subscriptions :: Traversal' (AppState a) EJsonValue Source
A helper lens into the subscription data inside the collections section of the dynamic app state.
Example:
>>>
:set -XOverloadedStrings
>>>
_collections $ set (subscriptions . _EJObjectKey "songs") (Just ejnull) (AppState undefined ejnull undefined)
null
setServerID :: DeadpanApp () Source
A client that sets the session id if the server sends it {"server_id":"83752cf1-a9bf-a15e-b06a-91f110383550"}
The handler deletes itself when the session is set.
putInBase :: Text -> EJsonValue -> DeadpanApp () Source
setSession :: DeadpanApp GUID Source
A client that sets the server_id if the server sends it {"msg":"connected","session":T6gBRv5RpCTwKcMSW}
TODO: The handler deletes itself when the session is set.