I could be nice to support error when using can with unexpected even:
var fsm = StateMachine.create({
initial: 'hungry',
events: [
{ name: 'eat', from: 'hungry', to: 'satisfied' },
{ name: 'eat', from: 'satisfied', to: 'full' },
{ name: 'eat', from: 'full', to: 'sick' },
{ name: 'rest', from: ['hungry', 'satisfied', 'full', 'sick'], to: 'hungry' },
]})
fsm.can('sleep');
produces the following error:
.can = function(event) { return !this.transition && (map[event].hasOwnProp
^
TypeError: Cannot call method 'hasOwnProperty' of undefined
It may be possible to return false instead of getting an error?
I'm writting a parser using state machine mechanism, so all my transitions depend on the input source that I cannot control that why I can stay in this use case :)
I could be nice to support error when using can with unexpected even:
produces the following error:
It may be possible to return
falseinstead of getting an error?I'm writting a parser using state machine mechanism, so all my transitions depend on the input source that I cannot control that why I can stay in this use case :)