How to manage notifications
I am trying to understand how to listen to notifications emitted from my resource actions and pass it down to a React client using Channels.
Currently this is what I've got:
I am able to successfully join to my channel from my React client. But I get this error when a new event is triggered from my resource:
The error is gone when I transform the notification
But I am still unsure of what is going on in here. How is the notification being sent to the client? I tried to inspect on the
But nothing seems to be happening there
Currently this is what I've got:
I am able to successfully join to my channel from my React client. But I get this error when a new event is triggered from my resource:
The error is gone when I transform the notification
But I am still unsure of what is going on in here. How is the notification being sent to the client? I tried to inspect on the
handle_out/2 callback:But nothing seems to be happening there
Solution
Okay, figured it out thanks to the realworld-phoenix-inertia-react project.
Turns out I shouldn't have created a channel to connect from my client with the same topic the resources emit the events to. They should be different — that's what was causing the weird behavior and the "ghost" and uncontrolled sending of data through my channel.
Now my action is publishing to the topic
I am subscribing to that topic from within the
And listening for events in
This works!
Turns out I shouldn't have created a channel to connect from my client with the same topic the resources emit the events to. They should be different — that's what was causing the weird behavior and the "ghost" and uncontrolled sending of data through my channel.
Now my action is publishing to the topic
notes instead of workspaceI am subscribing to that topic from within the
join/3 channel callback And listening for events in
handle_info/2 callbacksThis works!
