WIP xstate for dart & flutter
CD Player:
final machine = Machine.fromJson({
"key": "cd",
"initial": "not_loaded",
"states": {
"not_loaded": {
"on": {"INSERT_CD": "loaded"}
},
"loaded": {
"initial": "stopped",
"on": {"EJECT": "not_loaded"},
"states": {
"stopped": {
"on": {"PLAY": "playing"}
},
"playing": {
"on": {
"STOP": "stopped",
"EXPIRED_END": "stopped",
"EXPIRED_MID": "playing",
"PAUSE": "paused"
}
},
"paused": {
"initial": "not_blank",
"states": {
"blank": {
"on": {"TIMER": "not_blank"}
},
"not_blank": {
"on": {"TIMER": "blank"}
}
},
"on": {"PAUSE": "playing", "PLAY": "playing", "STOP": "stopped"}
}
}
}
}
});
machine.start(); // not_loaded
machine.transition('not_loaded', 'INSERT_CD'); // loaded.stopped
machine.transition('loaded.paused', 'EJECT'); // not_loaded
machine.start()
, machine.transition(current, event)
& state.matches('state')
State(child: Machine ...
State(on: {"2": '#B'})
Machine.fromJson({})
ability to create machines with JSON SchemaMachine.fromSCXML('<></>')
ability to create machines with SCXMLMachine.fromJson({})
& Machine.fromSCXML('<></>')
to Machine()
Machine()
to Machine.fromJson({})
or Machine.fromSCXML('<></>')
machine.maches('state.state_that_doesnt_exists')
validation. (throw state_that_doesnt_exists doesn't exists on the machine)