In-memory GenServer that captures messages pushed by SlackSandbox and
broadcasts them over PubSub so a live view (or anything else) can render
them as they arrive.
Add it to your supervision tree:
children = [
{SlackSandbox.Inbox, pubsub: MyApp.PubSub}
]:pubsub is required — it must be a PubSub name already running in your
supervision tree (the same one you pass to Phoenix.PubSub.subscribe/2
elsewhere in your app). :max_messages (default 200) caps how many
messages the inbox retains; oldest messages are dropped first.
Summary
Functions
Returns a specification to start this module under a supervisor.
Clears the inbox.
Lists captured messages, oldest first.
Returns the PubSub name this inbox was started with, for subscribing.
Pushes a message into the inbox and broadcasts it. Returns :ok.
Starts the inbox. :pubsub is required. Pass name: nil to start it
unregistered (useful for running more than one, e.g. in tests).
The PubSub topic messages are broadcast on, as {:message, message}.
Types
@type message() :: map()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec clear(GenServer.server()) :: :ok
Clears the inbox.
@spec list(GenServer.server()) :: [message()]
Lists captured messages, oldest first.
@spec pubsub(GenServer.server()) :: atom()
Returns the PubSub name this inbox was started with, for subscribing.
@spec push(message(), GenServer.server()) :: :ok
Pushes a message into the inbox and broadcasts it. Returns :ok.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the inbox. :pubsub is required. Pass name: nil to start it
unregistered (useful for running more than one, e.g. in tests).
@spec topic() :: String.t()
The PubSub topic messages are broadcast on, as {:message, message}.