xstate.dart
xstate.dart copied to clipboard
[WIP] Implementation Plan
Machine Definition
Defining https://www.w3.org/2011/04/SCXML/scxml.xsd with dart models.
Translation
Convert a machine that user provides to the machine definition format.
-
machine.fromJson
: xstatejs format -
machine.fromSCXML
: scxml format
Interpreter
An interpreter takes one Machine Definition (required), one Initial State and zero or more hooks and returns a Machine Instance.
Hooks
hook to an internal event of the interpreter. (onRaiseError
, onStateChanged
, ... )
Machine Instance
provides these properties:
-
Stream<State> state
: current state of the machine-
State
:-
value
: current state value -
matches(State pattern)
: check if the state matches a pattern -
context
-
-
-
void send(Event event)
: sends event to the machine
Flutter
- Basic binding for flutter
- Provide a simple example
Basic Tooling
- Machine definition validation & auto completion
- provide schema validation for
Machine.fromJson
with https://github.com/davidkpiano/xstate/pull/960/files#diff-573778b9503823ca0d77478e05c11054 - provide validation for
Machine.fromSCXML
with https://www.w3.org/2011/04/SCXML/scxml.xsd - provide auto completion for target transition states
- provide error for invalid or impossible transitions
- provide schema validation for
- state.matches() validation & auto completion
- provides all possible patterns for the machine.
- provide errors for invalid pattern
- state.context suggestion and type validation
Hey @sahandevs! I'd love to help out with this project, is there a particular area you could point me to as a good starting place?
Hi @ekweible! It would be awesome.
I've delayed this project but I will be back on it very soon. last thing I was working on was implementing the interpreter based on https://www.w3.org/TR/scxml (implemented part is here: https://github.com/sahandevs/xstate.dart/blob/master/packages/xstate/lib/src/interpreter/helpers.dart)
There are few todos there but the next thing i was going to work on was writing some test for the functions there. writing test for them should not be hard because they are bunch of independent function.
Thanks!