Set Keys of ReactiveVar object


I’m trying to do the following

Template.Collection.onCreated(function () {
    const self = this; = new ReactiveVar({});

//in some handler'buzz');

I’d then want to expect == {fizz:'buzz'}

My workaround for now is to create an object first, and then set foo to that. I.e.

const obj = {fizz:'buzz'};;

//then this works fine to retrieve the set obj
const results =; == {fizz:'buzz'};

Just wondering if there’s any roundabout way to achieve this in ReactiveVar so that I don’t have to introduce another temporary variable.

Any insights?‘buzz’);

That is not valid javascript. Try:{fizz:'buzz'});

You may want to use a Reactive Dict instead:


Sorry, that was a typo. I meant more in terms of how to set keys to the object after. I.e.{fizz:'buzz'});

is gonna make it so that foo is always that object. But what if I wanted to add another key? Any way to do that in the library itself, or ReactiveDict the alternative?{fizz:'buzz', foo: 'bar'});

Now it has two keys!

But really, If you want to track key value pairs independently, use a ReactiveDict: = new ReactiveDict();'fizz', 'buzz');'fizz') == 'buzz' // true'foo', 'bar');'fizz') == 'buzz' // true'foo') == 'bar' // true

Perfect, thanks so much for the example