carlgleisner
Examples usage of Oban with Phoenix PubSub
Hi all ![]()
I looked at using oban_notifiers_phoenix for PubSub in Phoenix but neither the tests in the GitHub repo nor the documentation gives any examples of how to subscribe to these notifications.
I did search GitHub but couldn’t find any use of the package in the wild so to speak.
Wouldn’t it be terrific with examples setting out how to subscribe?
I would sure need some at least
Or I’m just missing something fundamental regarding its intended use I guess.
Asking for a friend etc.
Most Liked
sorentwo
The oban_phoenix_pubsub package is only an adapter rather than a module you’d call directly. There’s an example of how to listen, notify, and receive notifications in the Oban.Notifier module: Oban.Notifier — Oban v2.23.0.
The listen/2 and notify/2 functions also have some examples.
arcyfelix
Isn’t this what you are looking for?
test "broadcasting notifications to subscribers" do
:ok = Notifier.listen(:signal)
:ok = Notifier.notify(:signal, %{incoming: "message"})
assert_receive {:notification, :signal, %{"incoming" => "message"}}
end
The first test shows how to listen to the notifier (aka subscribe) and how to send a signal.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









