this.$subscribe is not a function (was: Meteor subscription arguments)
gustojs opened this issue · 8 comments
Is it possible to provide an argument for Meteor subscription using vue-supply
?
Absolutely, follow the vue-meteor-tracker documentation for $subscribe
usage.
@Akryum thanks for the answer and sorry for disturbing, I know you're already pretty busy with all of that.
I'm using vue-meteor-tracker way to provide arguments for $subscribe, it's working fine at this end, but only as long as I don't do it in the supply Vue instance.
In particular, I am interested in the way to pass an argument from the component where I use the mixin to the subscription Vue instance, so that I have the actual value to pass to the subscription, which would come f.e. from an input field - the most common use case being a filter to search the documents with. THIS WAS SOLVED, SOLUTION IN THE NEXT COMMENT.
By the way, I tried to test your Meteor example. First thing I noticed is that the example doesn't extend Supply object. But that's an easy fix.
Then, I noticed that even if this.$subscribe
works fine in my components, it is not a function in the supply activate() method.
I kind of solved it by importing VueMeteorTracker to the supply file and doing Vue.use(VueMeteorTracker)
once again - this.$subscribe started working.
Sadly, it worked only until I updated Meteor to the newest 1.4.3.2 (previously I was on 1.4.2) which resulted in meteor import error coming from VueMeteorTracker. This was probably the reason for the latest fix in VueMeteorTracker, so I updated your package to the latest version too.
VueMeteorTracker 1.1.2 suddenly decided that it doesn't like to be called in the supply file anymore. If I do it, it results with Error: Can't call yield in a noYieldsAllowed block!
coming from VueMeteorTracker plugin. But if I don't, I get the this.$subscribe is not a function
error.
I hope that helps you somehow with potential issues. I can provide a repro if you want.
I'll look into all that! 😄
Thanks.
As for the main topic, I finally realized how to do that. If I do:
mixins: [use(Items)]
I can set the filter in Items by directly changing Items.filter.
That was probably too easy to notice.
The thing to have in mind is that a Supply is just a standard Vue instance augmented with some properties/methods.
So the only remaining question is, how to make the Supply be aware of the this.$subscribe
function.
This should be fixed in the new vue-supply 0.2
@gustojs you wrote:
I can set the filter in Items by directly changing Items.filter.
I'm not sure how to do that. Can you elaborate?
also, perhaps someone can explain how can I prevent the supply component from being automagically grasp'ed and activated during mixins: [use(Items)]
?
In my case this happens before the calling component gets to pass the supply component the subscription arg (which it receives as a prop). The result is that the subscription is started without the necessary args (and fails)