jakesgordon / javascript-state-machine

A javascript finite state machine library
MIT License
8.69k stars 964 forks source link

Bug? can() and cannot() fail when asking about wildcard transition that accepts args #133

Open adami opened 7 years ago

adami commented 7 years ago

I started using fsm.cannot(transition) to see if my fsm can handle the incoming transition before applying it.

It looks like using it for wildcard transitions that accept args (e.g. the famous "goto") returns the wrong result. If I understand correctly, it's because these methods use the seek() method that tries to use the args to see which state the wildcard is sending the fsm to, but can() and cannot() are not passing it.

As a workaround i use fsm.transitions().includes(transition) that i think does what fsm.can() is supposed to do.