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

Read data after subscribe #5

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hello, How can I get the json result when I subscribe to a colleciton ?

ocram commented 9 years ago

It seems you found the solution yourself already. But for others who may have the same question, here is how it's done:

If you subscribe to data from the server via mMeteor.subscribe(...), you will automatically receive all updates via the onDataAdded(...), onDataChanged(...) and onDataRemoved(...) callbacks that you implemented from the MeteorCallback class, e.g.:

public class MainActivity extends Activity implements MeteorCallback {
    ....
}

You may take a look at the source here: https://github.com/delight-im/Android-DDP/blob/2bc95f60a4c6ee4c0d0b31fae396a4076e9b8fcd/Android/Source/src/im/delight/android/ddp/Meteor.java#L834