jakesgordon / javascript-state-machine

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

onEnter<STATE> does not work for camelCase state names? #117

Open adami opened 7 years ago

adami commented 7 years ago

i have a state called 'ShowDisclaimer'. when the state machine moved to that state, the onEnterShowDisclaimer or onShowDisclaimer were not called. I added a general onEnterState method to make sure that the state is reached, so i know it got there.

when i changed the state name to 'Show' or 'Showdiclaimer' it did work. looked for naming limitations addressing this but can't find any.

bug?

adding input: if i change the state name to show_disclaimer, the onShowDisclaimer function is called. so it does convert state names to camelCase correctly, but having problems if it was initially a camelCase?

update: OK, looked at code. state has to start with lowercase. OK now, although weird that it lets it be a single word with first uppercase but not multiple words.

st31ny commented 5 years ago

In the current version the problem is still present. If a state name is in camelCaseState I have to use 'onCamelcasestate'. However, transition names work fine, so a camelCaseTransition can be observed with 'onCamelCaseTransition'.

As I understand the documentation, this is a bug.