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

feat: Add FiniteStateMachine #111

Merged
merged 10 commits into from
Jul 3, 2024
Merged

feat: Add FiniteStateMachine #111

merged 10 commits into from
Jul 3, 2024

Conversation

idan
Copy link
Contributor

@idan idan commented Jul 2, 2024

Update: per @Hugos68 feedback, I converted to a class and renamed to FiniteStateMachine. Otherwise, no changes to the initial PR.

Adds a new useFSM rune that allows you to create minimalistic finite state machines.

Ported over from https://github.com/githubnext/tiny-svelte-fsm (which was already MIT, and I'm the author there). I made a couple of minor fixes along the way as well, mostly to enable people to call .debounce in actions and lifecycle handlers.

This PR includes:

✅ Docs with an interactive demo and examples
✅ Tests

Per our conversation in the Svelte Discord:

CleanShot 2024-07-02 at 16 41 57@2x

Copy link

changeset-bot bot commented Jul 2, 2024

🦋 Changeset detected

Latest commit: c9fd7f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
runed Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jul 2, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ✅ Ready (View Log) Visit Preview c9fd7f7

@idan
Copy link
Contributor Author

idan commented Jul 2, 2024

A lil' demo video of the demo at the top of the docs:

CleanShot.2024-07-02.at.16.49.32.mp4

@idan idan changed the title feat: Add useFSM feat: Add FiniteStateMachine Jul 2, 2024
@Hugos68
Copy link
Collaborator

Hugos68 commented Jul 2, 2024

Could you capitalize the types in the example code? It's a typescript convention.

Copy link
Member

@TGlide TGlide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, thank you so much! Left a few comments :)

@TGlide TGlide added the enhancement New feature or request label Jul 2, 2024
Thanks @TGlide for the excellent review.
@idan
Copy link
Contributor Author

idan commented Jul 2, 2024

@TGlide thanks, what a lovely review.

I fixed all the things except for the generic vs type assertion. I don't have a better idea, but from a DX perspective, I definitely want the current state to be of type StateT not StateT | undefined or anything like that.

@idan idan requested a review from TGlide July 2, 2024 20:45
Copy link
Member

@TGlide TGlide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again! LGTM 🎉

@TGlide TGlide merged commit 9c0db5a into svecosystem:main Jul 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants