Skip to content

Releases: optimizely/nuclear-js

1.0.1

27 Apr 20:12
Compare
Choose a tag to compare

Added

  • Expose createReactMixin functionality on Nuclear singleton

Fixed

  • Fix new Store() from throwing error when not passed a config object

1.0.0

25 Apr 23:18
Compare
Choose a tag to compare

Production ready release.

What's New

  • Huge optimizations for Reactor.evaluate and Reactor.observe - These values are now very efficiently memoized by leveraging that fact that getters are pure functions and are transforming immutable data. This means that complex transformations wont be reevaluated unless its direct dependencies or underlying state change.
  • Built in support for React - No need for the NuclearReactMixin, simply use reactor.ReactMixin

Breaking Changes

Reactor API

The Reactor.get and Reactor.getJS methods have been simplified. They no longer multiple arguments of keypaths and getters. Instead they take a single getter or keypath and return a value.

  • Reactor.get( ...getters, transformFn ) -> Reactor.evaluate( getter )
  • Reactor.getJS( ...getters, transformFn ) -> Reactor.evaluateToJS( getter )

More Structured KeyPaths

In Nuclear 0.5.x the following where all valid KeyPaths

'foo.bar'
// or
['foo', 'bar']

To promote less ambiguity in the code, Getters may only take the following form:

['foo', 'bar']

Getter Format Change

Getters are no longer a constructor, instead they are plain arrays of the form:

[ keyPath, keyPath, transformFn ]

Previously in 0.5.x

var Getter = require('nuclear-js').Getter
var reactor = require('./reactor')

var filteredUsersGetter = Getter(
  'users.active', 
  'usernameFilter', 
  function(activeUsers, filter) {
    return activeUsers.filter(function(user) {
      return user.get('username').indexOf(filter) !== -1
    }
  }
)

reactor.get(filteredUsersGetter)

In 1.0.0 they take the form:

var reactor = require('./reactor')

var filteredUserGetter = [
  ['users', 'active'],
  ['usernameFilter'],
  function(activeUsers, filter) {
    return activeUsers.filter(user) {
      return user.get('username').indexOf(filter) !== -1
    }
  }
]

reactor.evaluate(filteredUserGetter)