New features
-
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. -
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
- 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 thestate
it receives inmodel.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),
})