StoneCypher / fsl

Finite State Language specification
9 stars 1 forks source link

One-time next-access hooks #1272

Open StoneCypher opened 10 months ago

StoneCypher commented 10 months ago

Saw a good comment criticizing XState on Reddit. Reached out to its author u/tossed_ to ask about opinions.

They dropped several good new features.

One is the idea of a hook that only fires the next time you hit some specific state. The example they gave was of a car waiting at a traffic light, rather than the light itself, wanting to know when next-green hits so that it could proceed.

This is a good idea, but it has some mismatch with the current API.

  1. It's not clear if this is actually a hook or not.
    1. It could be cast as another hook variant set, but do we really want hook_post_entry_once? API proliferation sucks.
    2. It could be a config argument passed to a hook
  2. If it is a hook
    1. Hooks are unitary - hook something and the old hook is removed. This wouldn't want to be, which is a conflict
    2. Should these remove hooks, even though they're going away?
  3. If it isn't a hook
    1. Why is it shaped so much like a hook
    2. What do we call it
  4. Either way
    1. Is this just transitions, or also actions
    2. If you action a 'foo' -> b, does the one-time fire? Hooks wouldn't, but it seems like this ought to
    3. Does this do other things, like next error, next tape, etc?