Boltun
Provides macros to define a listener and its callbacks. See the example below
defmodule TestListener do
use Boltun, otp_app: :my_app
listen do
channel "my_channel", :my_callback
channel "my_channel", :my_other_callback
channel "my_other_channel", :my_other_callback
end
def my_callback(channel, payload) do
IO.puts channel
IO.puts payload
end
...
end
Summary↑
channel(channel, function, args \\ []) | Defines a callback for the given channel, function and optional arguments. The callback must be defined in the same module using this macro |
channel(channel, module, function, args) | Defines a callback for the given channel, module, function and arguments |
listen(list1) | Defines the listener and its callbacks. Multiple callbacks per channel are supported and they will be invoked in in the order in which they appear in this block |
Macros
Defines a callback for the given channel, function and optional arguments. The callback must be defined in the same module using this macro.
Defines a callback for the given channel, module, function and arguments.
Defines the listener and its callbacks. Multiple callbacks per channel are supported and they will be invoked in in the order in which they appear in this block