Formular.Client.PubSub (formular_client v0.4.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

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

compile_event_metadata()

Specs

compile_event_metadata() :: [mod: module(), context: module()]
Link to this type

compile_failed_event()

Specs

compile_failed_event() ::
  {:compile_failed, formula_name(), err :: any(), code(),
   compile_event_metadata()}
Link to this type

compiled_event()

Specs

compiled_event() ::
  {:compiled, formula_name(), code(), compile_event_metadata()}

Specs

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 :: 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.