Skip to content

1.1.0

Compare
Choose a tag to compare
@jordangarcia jordangarcia released this 23 Jul 18:14
· 128 commits to master since this release
  • [NEW] added Reactor#serialize, Reactor#loadState, Store#serialize and Store#deserialize methods
  • [NEW] added Reactor#batch to allow batch dispatches before notify observers
  • [NEW] throw error when trying to dispatch within a dispatch
  • [FIXED] fix Evaluator locking if getter evaluation errors

Isomorphic Story

NuclearJS now supports server side rendering better than ever with NuclearJS React Addons.

To see this in action, check out the Isomorphic Flux Chat Example.

API Additions

Reactor#serialize()

Returns a plain JavaScript object representing the application state. By default this maps over all stores and returns toJS(storeState).

reactor.loadState(reactor.serialize())

Reactor#loadState( state )

Takes a plain JavaScript object and merges into the reactor state, using store.deserialize

This can be useful if you need to load data already on the page.

reactor.loadState({
  stringStore: 'bar',
  listStore: [4,5,6],
})

Store#serialize

Serialization method for the store's data, by default its implemented as `Nuclear.toJS' which converts ImmutableJS objects to plain JavaScript.
This is overridable for your specific data needs.

// serializing an Immutable map while preserving numerical keys
Nuclear.Store({
  // ...
  serialize(state) {
    if (!state) {
      return state;
    }
    return state.entrySeq().toJS()
  },
  // ...
})

Store#deserialize

Serialization method for the store's data, by default its implemented as `Nuclear.toImmutable' which converts plain JavaScript objects to ImmutableJS data structures.
This is overridable for your specific data needs.

// deserializing an array of arrays [[1, 'one'], [2, 'two']] to an Immutable.Map
Nuclear.Store({
  // ...
  deserialize(state) {
    return Immutable.Map(state)
  },
  // ...
})

Shoutouts

Huge thanks to @Sinewyk for spearheading all of the isomorphic work and updating the examples.

Also big things to @bhamodi @balloob @mark-rushakoff @kurumpa for their contributions this release.