tim2CF

tim2CF

Phoenix pubsub asterisk symbol support?

Let’s say we have a code

iex(1)> Phoenix.PubSub.subscribe Foo.PubSub, "user:*"
:ok
iex(2)> :erlang.process_info(self, :messages)
{:messages, []}
iex(3)> Phoenix.PubSub.broadcast Foo.PubSub, "user:1", :foo
:ok
iex(4)> :erlang.process_info(self, :messages)
{:messages, []}

Looks like phoenix_pubsub does not support asterisk symbol - "user:*" or "user.*" not worked for me. Is there any fundamental reason why it don’t support this functionality? Will be very useful for models/topics with big amount of fields (where amount of possible permutations is huge) like "user.*.currency.BTC.country.*"

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

@tim2CF it’s not supported because explicit support isn’t necessary, you can just publish to a user:*" topic every time you call publish and voila, now you have support for that. Topics are simple strings with no implicit structure which allows you to handle any approach you want.

easco

easco

I believe the ability to use the * wildcard is a feature of Phoenix Channels, and not built into the PubSub system itself. When creating a channel you can tell Phoenix that you want a particular Channel module to handle all the broadcast messages matching a particular pattern, but I don’t think you can subscribe to a PubSub with wildcards.

Where Next?

Popular in Questions Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement