inProgress-team / react-native-meteor

Meteor Reactivity for your React Native application :)
MIT License
693 stars 210 forks source link

Question: Access to subscriptionId in DDP 'added' event #217

Open JulianKingman opened 7 years ago

JulianKingman commented 7 years ago

Hey guys,

I'm working on a thorny issue (https://github.com/DesignmanIO/react-native-meteor-redux/issues/29), basically I need to be able to sync documents when I come online again. The difficulty is knowing when a particular document has been removed while offline, vs when it's just been unsubscribed from. My proposed solution for this is to store a lookup table for each unique subscription (a unique subscription being it's name + stringified params), associating it with the document _ids that it fetches. The problem is I can't figure out where information on both the subscription and documents is available at the same time. Ideally, I'd be able to use the ddp added, removed, and changed hooks, and know which subscription is producing those documents. My suspicion is that it's not that easy... If there are multiple pub/subs, then the docs are probably sent in aggregate. There must be some way to tell what docs are being sent by a subscription?

It looks like the Meteor subscription includes _subscriptionId into it's this property.