Meteor - Stop Reactivity on ONE variable

In Meteor, how can I stop reactivity on an ONE variable?

I want all other variables to be reactive, with the exception of one variable. Is it possible?

+4
source share
3 answers

You can achieve this with Tracker.nonreactive.

Unverified example:

// Get a session value in a non reactive way.
var myValue = Tracker.nonreactive(function(){
    return Session.get('theKey')
})

// Use myValue however you please.
+5
source

just create a non-reactive varaible with "var name = 'John';"

0
source

While this Tracker.nonreactive()is a general approach (any reactive source can wrap), for ReactiveVaryou can use a simpler solution:

someReactiveVar.curValue

This is what it get()also uses behind the scenes .

0
source

All Articles