I’m struggling with reactivity
I have a class that exists on both the server and the client. In it’s constructor I want to pull in a document from a collection and set it to this._config
.
export class AAM_Access {
constructor() {
this._id = "access";
this._source = Configuration.find({_id : this._id});
this._config = Configuration.findOne({_id : this._id});
self = this;
Tracker.autorun(function(){
self._config = self._source.fetch()[0];
});
}
}
With this I’m getting an error on the server:
Error: Can't call yield in a noYieldsAllowed block!
I’m guessing this has something to do with calling .fetch()
inside the Tracker.autorun. I would like this._config
to be reactive, but I’m a little lost on how to go about it.
Any help would be fantastic
EDIT: I do have 2 classes that extend this class, one for server one for client, just like Accounts_Server, Accounts_Client extend Accounts_Common. Might it be better to pull in the document in their constructors instead of in the common parent class?