Closed shantanubhadoria closed 9 years ago
Thanks for your question!
The string that is returned is just the subscription ID, which is not related to the actual data in any way.
The official Meteor documentation should make this clear. When you're subscribing, you're not getting data immediately. The data is returned whenever something changes, and delivered via the callbacks.
The subscription ID is only used for cancelling the subscription later, if needed.
Thus, all in all, this means that you can subscribe to whatever complex data structure you can imagine ;)
I have to admit, I am a rookie in Java and Android native. But how is the subscription ID then used to get the data that we actually need to render in the UI? Thanks
No problem!
You don't get the data as a result of that method call but via the callbacks that have been defined by implementing MeteorCallback
and calling mMeteor.setCallback(this)
.
These callback methods are onDataAdded(...)
, onDataChanged(...)
and onDataRemoved(...)
.
Please take a look at the README again which describes all this :)
I still do not understand how to handle data with subscription id in onDataAdded, onDataChanged, onDataRemoved,, could you give me some example code, please,, Thank you
Does this help?
Thanks for your code, in theory this fits in nicely with what I am trying to do.
I saw a subscribe method in documentation that returns a string String subscriptionId = mMeteor.subscribe("my-subscription");
Since this example is just string and I might want to subscribe to more complicated data structure than a plain string. like a row in MongoDB. How would I go about doing that? would I have to subscribe to each individual column seperately?
Is there a example code for how one may dynamically subscribe to a bigger collection data and update the UI on the fly without too much code? From the current examples in the documentation its not very easy to know if this is possible. Thanks!