Version 3.0.0
Breaking changes
This switches from the deprecated immutable-store to using Baobab to
store immutable state. Because the API for Baobab is
different there are breaking changes in how state is manipulated, but
there is also one big benefit: no need to call emitChange() when state
is updated because freezer has an event API that notifies when any state
changes.
The README was also updated and re-arranged to try and group related
concepts together.
BREAKING CHANGES:
- Immutable state must be created in the
initializemethod of a store
usingthis.immutable() - State must be fetched using
state.get() - State must be updated using the Baobab API
- Event wildcards have been replaced with listening to a specific path
on the state tree
An example of a version 2 immutable store:
angular.module('app', ['flux'])
.store('MyStore', function (flux) {
var state = flux.immutable({ items: [] });
return {
handlers: {
'addItem': 'addItem'
},
addItem: function (item) {
state = state.person.push(item);
this.emitChange();
},
exports: {
get items() {
return state.items;
}
}
};
});would now be:
angular.module('app', ['flux'])
.store('MyStore', function (flux) {
return {
initialize: {
this.state = this.immutable({ items: [] });
}
handlers: {
'addItem': 'addItem'
},
addItem: function (item) {
this.state.push('items', item);
},
exports: {
get items() {
return this.state.get('items');
}
}
};
});Other updates
- dispatchr was updated to the latest version
- codebase converted to es6