dunglas / mercure

🪽 An open, easy, fast, reliable and battery-efficient solution for real-time communications
https://mercure.rocks
GNU Affero General Public License v3.0
3.98k stars 296 forks source link

Can client set custom payload to choose its own subscriptions ? #458

Closed yobud closed 3 years ago

yobud commented 3 years ago

Hi!

I'm thinking about how to integrate mercure into a large marketplace app.

Imagine it does have plenty of Stores, with plenty of Products. I'm a Customer and I have added 50 Products in my cart, from various Stores.

I want to know when any of these Products has it price changed by the store owner.

Wouldn't be inefficient and slow to have 50 EventSources (one for each product) ?

I could subscribe on /products but then, if I have more than 50k products which are constantly modified by store owners, wouldn't it be a waste of data exchanges (and perfs on client side to analyse 50k editions to know if Customer is concerned) ?

Wouldn't it be great for my user to send his own payload to subscribe to a batch of products. And just close and reopen an EventSource when he adds a product to his cart (to add it in payload) ?

The only way I see to make this work is to send a request to my server with these subscriptions urls, which would return a specific token to be used as mercureToken.

Is this the way to do or is there something already developed for such case ?

Thank you

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.