Popularity
5.8
Growing
Activity
0.0
Declining
66
4
11
Monthly Downloads: 844
Programming language: Elixir
License: MIT License
Tags:
Utilities
pubsub alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view pubsub alternatives based on common mentions on social networks and blogs.
-
retry
Simple Elixir macros for linear retry, exponential backoff and wait with composable delays -
erlware_commons
Erlware Commons is an Erlware project focused on all aspects of reusable Erlang components. -
async_with
The asynchronous version of Elixir's "with", resolving the dependency graph and executing the clauses in the most performant way possible! -
plasm
Ecto's composable query multitool (.count, .random, .earliest, .latest, .find, .at, .on, etc.) -
sips_downloader
Utility to download Elixir Sips screencast videos written in Elixir (subscription to Elixir Sips required) -
ar2ecto
Migrate your active record migrations to ecto compatible migrations -
ex_progress
A library for tracking progress across many tasks and sub-tasks -
exjprop
Elixir library for reading Java properties files from various sources. -
fitex
FitEx is a Macro-Module which provides a bit of sugar for function definitions.
Elixir and Phoenix Application Security Platform
Replace Snyk, reCaptcha, and Cloudflare bot defense with the only application security platform built for Elixir and Phoenix.
Promo
paraxial.io
Do you think we are missing an alternative of pubsub or a related project?
Popular Comparisons
README
Elixir Publish/Subscribe
A Publish/Subscribe utility module that frees your business logic processes from the burden of communication.
Getting Started
Add :pubsub
as a dependency to your mix.exs
file:
defp deps do
[
{:pubsub, "~> 1.0"}
]
end
Then run mix deps.get
in your shell to fetch the dependencies.
Examples
Assuming your client process looks like this:
defmodule Client do
def start(client_name) do
spawn(fn -> loop(client_name) end)
end
def loop(name) do
receive do
message ->
IO.puts "#{name} received `#{message}`"
loop(name)
end
end
end
With PubSub
you can do this:
iex(1)> {topic1, topic2} = {:erlang, :elixir}
{:erlang, :elixir}
iex(2)> {:ok, pid} = PubSub.start_link()
{:ok, #PID<0.99.0>}
iex(3)> {pid1, pid2, pid3} =
...(3)> {
...(3)> Client.start("John"),
...(3)> Client.start("Nick"),
...(3)> Client.start("Tim")
...(3)> }
{#PID<0.106.0>, #PID<0.107.0>, #PID<0.108.0>}
iex(4)> PubSub.subscribe(pid1, topic1)
:ok
iex(5)> PubSub.subscribe(pid2, topic1)
:ok
iex(6)> PubSub.subscribe(pid3, topic2)
:ok
iex(7)> PubSub.publish(topic1, "#{topic1} is great!")
"Nick received `erlang is great!`"
"John received `erlang is great!`"
:ok
iex(8)> PubSub.publish(topic2, "#{topic2} is so cool, dude")
"Tim received `elixir is so cool, dude`"
:ok