Reputation: 4437
To set a session variable I must use Session.set('foo', 'sampletext')
. But what if foo is an object foo: {bar: 'sample', xyz: 'text'}
and I just want to change foo.bar
?
Upvotes: 0
Views: 50
Reputation: 64312
Session
doesn't support this. You'd need to replace the whole object:
var foo = Session.get('foo');
foo.bar = 'something';
Session.set('foo', foo);
However, Session
is just an instance of a ReactiveDict, which does support this:
var fooDict = new ReactiveDict('foo');
fooDict.set('bar', 'something');
As long as you name the ReactiveDict
, it will survive a hot code push and give you the same benefits of Session
.
Upvotes: 2