Setting Multiple Session Values at Once - Bug?

After reading the latest “This Week In Meteor #3” I was keen to try out the ability to set multiple session variables at once. However, I use dot-notation in my session variable naming (perhaps wrongly!) to categorize related session variables together, so I had previously done the following (which worked):

  Session.set('', '');
  Session.set('healthMarks.create.countryCode', '');
  Session.set('healthMarks.create.establishmentCode', '');

After attempting the “new” way of setting them all in one go:

    '': '',
    'healthMarks.create.countryCode': '',
    'healthMarks.create.establishmentCode': ''

But the values remain set to their previous values. The following if statement in the ReactiveDict.set() code, returns false, and thus it thinks the old & new values are the same.

if (_.has(self.keys, key)) oldSerializedValue = self.keys[key];

Now I’m pretty darn sure this is an issue with using dot-notation in your session variable names, but perhaps that needs to be highlighted as a no-no in the documentation?

Hey if this is the case, it looks like a real bug. Please file a bug on GitHub with a complete reproduction in the form of an app.

As far as I am aware, I don’t need an app to reproduce it, its simply:

Session.set('', 'some random value');
Session.set({ '': '' });
console.log(Session.get('')); // > 'some random value'

Looks like the bug is in setting values to falsey values, not anything about dots.


Ah, well that is more of an issue than I thought!

It certainly doesn’t do it if you use the standard Session.set('name', value); syntax though.

It’s ok now, I think, we fixed it in time for the release.

Brilliant! I look forward to using it when the new version is released.