Working with Session Objects (complex sessions)?

A question about Sessions/UI-State:
I have a Layout with about ten different areas that can toggle in/out or expand/shrink.

I’m super happy with the result. However I’m wondering now how and where I store the information about such a complex UI State.


  1. A simple session for each of those areas
  2. Some kind of session object that contains information about all the areas? Sounds a bit cleaner. But then I don’t think there’s a session.update(),right? How would I just change part of the session object?

Thanks for your thoughts! :slight_smile:

Have you considered using a reactive-dict? You could manage your UI state in a single ReactiveDict instance, keeping it separate from the Session.

I don’t think Session is very good, tbh. There are a few alternatives, imho.

Why not make a toggle component with something like peerlibrary:blaze-components?

class Toggle extends BlazeComponent {
  onCreated() {
    this._toggled = new ReactiveField(false); // initialize false
  events() {
      'change input': e => this._toggled($('checked'))

Then you can just re-use it in multiple places and it would be its own instance. For example:

<ul class="toggle-list">
  {{>Toggle name="yes"}}
  {{>Toggle name="no"}}
  // ad infinitum

the MeteorFlux ReactiveState was an awesome choice for this scenario, but they stopped maintaining the MeteorFlux project in fear of Blaze+Tracker being deprecated sadly. It’s still usable so it may be worth a shot. It’s unfortunate because I think Meteor could really use a package like it for app state management that’s a little better than throwing everything into Session. ReactiveState is missing some necessary functionality though, like an equivalent to Session.equals()

1 Like