envio v0.3.2 Envio.Publisher behaviour View Source
Publisher helper scaffold.
use Envio.Publisher in the module that should publish messages.
broadcast/2 function becomes available. If the optional
argument is passed to
use Envio.Publisher, this channel is considered
the default one and
broadcast/1 function appears to publish directly
to the default channel.
The ready-to-copy-paste example of usage would be:
defmodule MyPub do use Envio.Publisher, channel: :main def publish(channel, what), do: broadcast(channel, what) def publish(what), do: broadcast(what) end
All the subscribers of the particular channel the message was published
to, will either receive a message (in the case of
or called back with the function provided on subscription
The publisher does not wrap
functionality since it makes not much sense.
For how to subscribe, see