Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add matches and nested APIs #119

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add matches and nested APIs #119

wants to merge 1 commit into from

Conversation

matthewp
Copy link
Owner

@matthewp matthewp commented May 14, 2020

This PR adds the following APIs:

  • <service>.matches(<string>)
    Returns true when the <service> is in the state named <string>, which includes nested states separated by dots ('.'); e.g. foo.bar indicates state foo in the toplevel machine and bar in the current child machine.
  • nested()
    Creates a state, similar to state, immediate and invoke; this state executes a child state machine

Closes #56

@HipsterBrown
Copy link
Contributor

This looks great! 👏 I also like the included nested helper for quickly creating child machines. 💯

Looks like the bundlesize just needs to be updated to get CI green. I wonder if it's possible to feed that bundle size data into the website, i.e. "Fast 1.48kb functional library for creating Finite State Machines"

@gkiely
Copy link
Contributor

gkiely commented Feb 1, 2023

@matthewp is there some additional work you would like to implement on this branch or is it able to be merged in?

If you'd like this merged, I'd be happy to address the conflicts and get it ready for review.

@matthewp
Copy link
Owner Author

matthewp commented Feb 1, 2023

@gkiely feel free to update the branch. I would like to take another look before we release it though. This might make a good 1.0 feature.

@matthewp
Copy link
Owner Author

matthewp commented Feb 2, 2023

This PR also needs docs before merging. And a changeset.

@ehuelsmann
Copy link
Collaborator

@matthewp I would have added .matches() and nested in separate changes, but I don't feel strongly about it. I think both additions to the API are valuable. Before we merge, I think it's necessary to add documentation to docs/{guides,api}. (Before we forget.)

@ehuelsmann
Copy link
Collaborator

ehuelsmann commented Dec 14, 2024

@matthewp going into the "multiple states" part of #56, you may consider .matchesAny(...stateNames) which iterates over state names calling .matches() until one returns true, or, given that .matches() isn't part of the API yet, simply make it variadic.

@matthewp
Copy link
Owner Author

I probably would break it up too. I actually think I feel better about matches than I do the nesting stuff. I need to get back around to finishing this. Want to keep it open as to not forget.

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

Successfully merging this pull request may close these issues.

Figure out a better way for matching the current state
5 participants