Setting ReactiveDict with an Object

Out of curiosity, is there a reason why setting the values of a ReactiveDict variable using an object isn’t documented?

What I’ve been doing:

let x = new ReactiveDict();
x.set('key1', 'value1');
x.set('key2', 'value2');

What I just tried:

let x = new ReactiveDict();
  'key1': 'value1',
  'key2': 'value2'

I ran into this when trying to _.mapObject something into a ReactiveDict and getting stringified objects, and for the heck of it tried just dumping the object into the ReactiveDict, which worked.

I saw the following comment in the ReactiveDict package:

// set() began as a key/value method, but we are now overloading it
// to take an object of key/value pairs, similar to backbone

Understandably, dumping a huge object into a ReactiveDict opens up the possibility of a ton of invalidations, but this also seems like a really easy way to get an object with nested pairs into a ReactiveDict.

Just wondering if there is a reason that the documentation for set() only references the key/value strategy. Tagging @sashko as you had the latest commits…

1 Like

Nope, no reason - feel free to submit a PR to the docs to add it!

1 Like