Gilou06

Gilou06

Phonenix.Pubsub.subscribe or MyApp.Endpoint.subscribe?

Hi there,
Is there a technical or philosophical difference between using one or the other ?
I end up using both in my code without understanding why.
Any help appreciated.
Thank you
:slight_smile:

Marked As Solved

LostKobrakai

LostKobrakai

Of the whole “pubsub” based api on the endpoint (8 funs) two happen to be mostly delegations. That’s what I consider “providing a complete api” instead of requiring users of channels to not only know how to fetch the pubsub module on their own, but also to look in multiple places for functionality, which is supposed to be one cohesive set. (Also removing API would need deprecation or even a major version release)

Phoenix channels align very much with pubsub api wise – which makes sense given pubsub was extracted out of the channels codebase – but it’s still a subset of pubsub in that it has some additional constraints around how messages need to look like and which information is provided by those messages for channels/sockets to be able to pick them up. Also as mentioned theres the fastlaneing optimizations.

That does affect even subscribing. If you use Phoenix.Endpoint.subscribe it’s reasonable to expect to receive only messages, which adhere to the format mentioned. If you subscribe with Phoenix.PubSub that assumption is off.

Plain Phoenix.PubSub is more low level than the channels based messaging.

Last Post!

Gilou06

Gilou06

Seing only today that there has been a follow-up on my question. Sorry for not tagging the answer earlier.

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement