subway v0.1.0 Subway.Subscriber behaviour

Behaviours to implement subscribers.

Link to this section Summary

Callbacks

Handles the supported_event

Checks if the broadcasted event is supported

Link to this section Callbacks

Link to this callback

handle(arg1, arg2)

handle(String.t(), Map.t()) :: :ok

Handles the supported_event

Example:

def handle(event_name, %{changeset: changeset, payload: payload}) do
  # Whatever logic you want to perform
  :ok
end
Link to this callback

supported_event?(arg1)

supported_event?(String.t()) :: boolean()

Checks if the broadcasted event is supported

Example:

def supported_event?(event_name) do
  regex = ~r/message/

  Regex.match?(regex, event_name)
end