Skip to content

v1.0.0-beta.2

Latest
Compare
Choose a tag to compare
@ruanyl ruanyl released this 21 Jun 14:04
· 5 commits to beta since this release

New features

  1. Supports the use of a plain object as the model state
    It only supports Immutable Record before, now with plain object support, users can choose to use immutability libs such as immer.

  2. Starts to support plugin which intercepts the reducer/action lifecycle and enables people to extend the framework via the plugin.
    For example, immer supports via plugin: reapex-plugin-immer

Breaking changes

  1. The initial state passed to app.model will not be converted to Immutable Record, it will be the same type as the data passed in.
    app.model accepts a plain object or an Immutable Record as initial state and the state it receives in model.mutations will be either plain object or Immutable Record based on the type of initial state.

For example:

const app = new App()
const model = app.model('counter', { total: 0 })
const [mutations] = model.mutations({
  // state here will be a plain object
  increase: () => state => ({total: state.total + 1}),
})

With Immutable Record:

const app = new App()
const CounterState = Immutable.Record({{ total: 0 }})
const initialState = new CounterState()
const model = app.model('counter', initialState)

const [mutations] = model.mutations({
  // state here will be an Immutable Record
  increase: () => state => state.set('total', state.total + 1),
})