@cloudspider Nice work, I’m glad you have started it! It would be super cool if we have such easy solution for vue!
I saw in source that you you such construction:
Vue.prototype.$subscribe = async (publicationName, ...args) => {
return api.sub(publicationName, ...args).ready();
};
But it won’t work as you expected, because simpleDDP.sub take a subscription name as a first argument and an array of parameters (optional) for the subscription as a second argument.
And in your example you use:
await this.$subscribe('articles').catch(console.error);
this.articles = await this.find('articles');
The last statement uses:
Vue.prototype.find = function(collectionName) {
const collection = api.collection(collectionName);
return collection.fetch();
};
However collection.fetch will return you not a promise but a raw js array of what you have in your collection or [ ] (if there is none). So you can’t await it.
As for the example code:
await this.$subscribe('articles').catch(console.error);
This line will guarantee you that you have something inside the collection, and when you fetch it using
this.find('articles');
You will receive a copy of what you have in your collection at the moment of fetching, it is not reactive.
SimpleDDP 1.2.0 is coming out and it will have zero-dependant reactive data source both for the collections, filtered collections and objects, built-in smart sorting, improved subscriptions. So I suggest to use reactive source inside your find function when it came out. I am working on guide right now!
P.S. I will make a PR to your repo.