Can PubSub be configured between 2 Liveviews on different routes directly without involving context functions?

I have an app that I’ve built that uses pub sub. The code configures a context function to subscribe and broadcast changes to liveviews.

In short, (if I understand correctly) as the database changes the message is broadcast to any liveviews that are subscribed and the updates take place in “realtime”.

I want to know if there is a way to wire up the pubsub functions between two liveviews on two different routes and have them subscribe and broadcast between each other without the involvement of the context functions.

In other words, if my app had no database and I wanted to pass data between two live views using pub/sub, is this possible?

I have no need to do this, I am asking solely to get a better understanding creatively.

I tried writing some code to do this and it didn’t work. I figure I should ask if it is even possible :slight_smile:

Sure, the context functions are entirely a code organization choice, they have nothing to do with the actual execution of the pubsub mechanism. If you subscribe to a topic in a LiveView and then publish to that topic anywhere else (including another LiveView) you will get that message.

2 Likes