How can I disable reactivity of reactive data source?



Suppose that I have two reactive data source, for example, Session.get(‘A’) and Session.get(‘B’).

I want an autorun that refers these two session variables and will be reactively computed triggering by the Session.get(‘A’) only.

Are there any ways to disable reactivity of Session.get(‘B’)?


Hi @new3rs,

According to documentation, you can use Tracker.nonreactive function - Example:

Template.Foo.onCreated(function () {
  this.autorun(function () {
    var session_A = Session.get('A');
    var session_B = Tracker.nonreactive(function () {
      return Session.get('B');


Thank you, amigasan!

I read meteor doc so many times but I have never seen this fuction^^;

Thanks, again.


I am quite sure that Tracker.nonreactive() has no return value, hence the session_b assignation should be done in the callback function, like this:

   var session_B = Session.get('b);
   // then do stuff with session_B


And I am 100% sure, that Tracker.nonreactive has return value :wink:


Didn’t know about that !


What would happen in this case?

 collection() {
        return Comments.find({},{reactive: false});
      comments() {
        var comments = this.getReactively('collection');

The comment helper is not calling itself again when collection is ready

And also if I desactive the reactivity I get no content:

return Comments.find({},{reactive: false}).fetch().map(comment => {
   console.log(comment); // with reactive: true I see some data but no with false