Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/customcommander/xmachina
A small DSL that compiles to XState.
https://github.com/customcommander/xmachina
dsl finite-state-machine state-machine tagged-template xstate
Last synced: 19 days ago
JSON representation
A small DSL that compiles to XState.
- Host: GitHub
- URL: https://github.com/customcommander/xmachina
- Owner: customcommander
- Created: 2023-09-14T23:00:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-08T21:49:26.000Z (about 1 year ago)
- Last Synced: 2024-01-29T08:48:25.533Z (12 months ago)
- Topics: dsl, finite-state-machine, state-machine, tagged-template, xstate
- Language: JavaScript
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
[[https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg]]
* XMachina
The goal of this project is to provide a concise yet
declarative language for state machines and to augment
the experience of working with [[https://github.com/statelyai/xstate][XState]].At this stage this is an educational project only and
I make no commitments to deliver anything useful
at any time.** TL; DR
#+begin_src javascript
import {interpret} from 'xstate';
import {xmachina} from '@customcommander/xmachina';const service =
interpret(xmachina`
machine question {
is_valid = ${(ctx, ev) => ev.answer === 42}initial state searching {
[ON_ANSWER]: is_valid? found
}final state found {}
}`);service.start();
service.send({type: 'ON_ANSWER', answer: 10});
// still searchingservice.send({type: 'ON_ANSWER', answer: 42});
// found answer!#+end_src
** Acknowledgment
When I initially set out to write this DSL, I didn't look
around for similar projects. However it didn't take long
until I came across [[https://github.com/lucydsl/liblucy][Lucy]].I suspect that XMachina will look similar to Lucy in many
ways, but it will also be different as I make my own design
decisions.I should also mention [[https://github.com/StoneCypher/jssm][JSSM]] and [[https://fsl.tools/][FSL]] for completeness
even though their goals are somewhat different than mine.Nonetheless people will eventually notice the similarities
and I just wanted to take this opportunity to thank and
give credit to the people who were on this journey
before me.Thank you!