delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Data added event on subscription #13

Closed iahvector closed 9 years ago

iahvector commented 9 years ago

Hi, I noticed that when a subscription is successful, an onDataAdded event is fired for each record of the data loaded by the subscription (data existing in the database up to the subscription time). Wouldn't the onDataAdded event be better fired only when new data is added after the subscription? The data loaded by the subscription can be delivered in the onSuccess callback of the SubscriberListener.

ocram commented 9 years ago

One could certainly do this, you're right.

But sending all records through onDataAdded(...), no matter if old or just created, is how Meteor and this library work.

Regarding the SubscribeListener, you got that right: By waiting for onSuccess(...) to be called, you know when the initial data set has been transferred.

So you can handle this yourself, however you want this to handle. Every user of this library is thus free to adapt this to their architecture: Some may just want to ignore the initial data set, some will want to store it locally, etc.

Anyway, you got all the concepts right and understood this correctly.