Copyright | (c) Well-Typed / Tim Watson |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | Tim Watson <watson.timothy@gmail.com> |
Stability | experimental |
Portability | non-portable (requires concurrency) |
Safe Haskell | None |
Language | Haskell98 |
- Overview
The EventManager is a parallel/concurrent event handling tool, built on
top of the Exchange API. Arbitrary events are published to the event
manager using notify
, and are broadcast simulataneously to a set of
registered event handlers.
- Defining and Registering Event Handlers
Event handlers are defined as Serializable m => s -> m -> Process s
,
i.e., an expression taking an initial state, an arbitrary Serializable
event/message and performing an action in the Process
monad that evaluates
to a new state.
- data EventManager
- start :: Process EventManager
- startSupervised :: SupervisorPid -> Process EventManager
- startSupervisedRef :: SupervisorPid -> Process (ProcessId, Message)
- notify :: Serializable a => EventManager -> a -> Process ()
- addHandler :: forall s a. Serializable a => EventManager -> (s -> a -> Process s) -> Process s -> Process ProcessId
- addMessageHandler :: forall s. EventManager -> (s -> Message -> Process (Maybe s)) -> Process s -> Process ProcessId
Documentation
data EventManager Source
Opaque handle to an Event Manager.
start :: Process EventManager Source
Start a new Event Manager process and return an opaque handle to it.
notify :: Serializable a => EventManager -> a -> Process () Source
Broadcast an event to all registered handlers.
addHandler :: forall s a. Serializable a => EventManager -> (s -> a -> Process s) -> Process s -> Process ProcessId Source
Add a new event handler. The handler runs in its own process, which is spawned locally on behalf of the caller.
addMessageHandler :: forall s. EventManager -> (s -> Message -> Process (Maybe s)) -> Process s -> Process ProcessId Source
As addHandler
, but operates over a raw Control.Distributed.Process.Message
.