Changelog
0.5.21
Commands will now use the id
property from the command object as a
fallback if the id argument is not provided to setState
.
// `onStateDidChange` will be called with (state, "added_message")
addMessage(newMessage) {
this.setState({
before: { message: this.state.message },
after: { message: newMessage }
}, "added_message")
}
// `onStateDidChange` will be called with (state, "cleared_message")
clearMessage() {
this.setState({
id: "cleared_message",
before: { message: this.state.message },
after: { message: "" }
})
}
// `onStateDidChange` will be called with (state, "flipped_message")
reverseMessage() {
this.setState({
id: "reversed_message",
before: { message: this.state.message },
after: { message: [...this.state.message].reverse().join("") }
}, "flipped_message")
}
Changes stack
from private to protected. This allows extending
classes to make the stack
public if they wish.
class Example extends StateManager {
get history() {
return this.stack
}
}
Changelog
0.5.20
onReady
method, which is called when the state loads
persisted data.Changelog
0.5.19
persist
method protected
rather than private
, so that you can manually call persist from sub-class methods.Changelog
0.5.18
Patch
and Command
type exportsChangelog
0.5.16
onStateWillChange
and onStateDidChange
during replaceState
.Changelog
0.5.15
onStateWillChange
onStateWillChange
Changelog
0.5.14
onStateDidChange
onStateDidChange
id
to Command
(optional)id
parameter (optional) to methods that change stateStateManager
methods, now correctly chainableChangelog
0.5.13
resetState
so that it returns to the provided initial state, rather than the restored persisted state.