Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Know if event is handled by state machine or not #357

Open
mogsie opened this issue May 27, 2015 · 0 comments
Open

Know if event is handled by state machine or not #357

mogsie opened this issue May 27, 2015 · 0 comments

Comments

@mogsie
Copy link
Contributor

mogsie commented May 27, 2015

When gen() is called, it returns the basic configuration of the state machine after processing the event. But sometimes the event is (correctly) ignored by the state machine. It is sometimes useful to detect these situations, e.g. so that DOM preventDefault() can be called in case the event is handled, and not call preventDefault() if the state machine didn't handle the event.

Imagine a situation where certain keystrokes are fed to the state machine (e.g. up, down, left, right) and that we want to prevent the default propagation of the keystroke event if and only if the state machine handled the event. I don't want to have to litter calls to e.preventDefault() events in the SCXML, as the SCXML is decoupled from the DOM itself, and introducing a dependency is unnecessary and ugly.

I was thinking that the response to gen could be null in the case where the event was not handled. It would probably break backward compatibility so it's not a feasible solution.

Is this at all interesting for other applications?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant