Formular.Client.PubSub (formular_client v0.3.0-alpha.1)
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Dispatch the event to all subscribers.
Shortcut to dispatch({:code_change, formula_name, old_code, new_code})
Subscribe the change events for a given formula.
Stop receiving events from dispatcher.
Link to this section Types
Link to this type
code()
Specs
code() :: String.t()
Link to this type
code_change_event()
Specs
code_change_event() :: {:code_change, formula_name(), old_code :: code(), new_code :: code()}
Link to this type
formula_name()
Specs
formula_name() :: String.t()
Link to this section Functions
Link to this function
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this function
dispatch(event)
Specs
dispatch(event :: code_change_event()) :: :ok
Dispatch the event to all subscribers.
Link to this function
dispatch_code_change(formula_name, old_code, new_code)
Specs
dispatch_code_change(formula_name(), old_code :: code(), new_code :: code()) :: :ok
Shortcut to dispatch({:code_change, formula_name, old_code, new_code})
Link to this function
start_link(args)
Link to this function
subscribe(formula_name, pid \\ self())
Specs
subscribe(formula_name(), pid()) :: :ok
Subscribe the change events for a given formula.
Notice that a subscriber can subscribe a formula change for multiple times. In such cases, it also needs to unsubscribe for the same amount of times to stop receiving messages.
Link to this function
unsubscribe(formula_name, pid \\ self())
Specs
unsubscribe(formula_name(), pid()) :: :ok
Stop receiving events from dispatcher.