View Source Surrealix.Dispatch (surrealix v0.1.2)

Handles callback registration (for only when using live queries). Based on ideas here: https://github.com/keathley/sync_dispatch

Summary

Functions

Attaches a function to an event. The provided id is used for idempotence. Different handlers should use unique handler ids.

Executes an event and any handlers that are attached to the event name. data can be any term().

Types

@type handler_function() :: ([atom()], term(), term() -> any())

Functions

Link to this function

attach(id, event, fun, config \\ nil)

View Source
@spec attach(term(), [atom()], handler_function(), term()) ::
  :ok | {:error, %Surrealix.AttachError{__exception__: true, message: term()}}

Attaches a function to an event. The provided id is used for idempotence. Different handlers should use unique handler ids.

@spec execute([atom()], term()) :: :ok | no_return()

Executes an event and any handlers that are attached to the event name. data can be any term().