Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rows/automata
A Dart DSL for finite state machine and state charts
https://github.com/rows/automata
dart flutter statemachines
Last synced: 5 days ago
JSON representation
A Dart DSL for finite state machine and state charts
- Host: GitHub
- URL: https://github.com/rows/automata
- Owner: rows
- License: bsd-3-clause
- Created: 2022-02-09T14:53:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-29T12:58:56.000Z (over 2 years ago)
- Last Synced: 2024-08-01T12:22:15.883Z (3 months ago)
- Topics: dart, flutter, statemachines
- Language: Dart
- Homepage:
- Size: 82 KB
- Stars: 47
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Automata
A dart package to create Finite State Machines and State Charts following [SCXML](https://www.w3.org/TR/scxml) specification.The main highlights of automata are:
- Declarative and type-based
- Compound states (nested states)
- Parallel states
- Initial states
- Guard conditions
- Eventless transitions
- Actions
- Invoke async services
- onEntry / onExit
- onTransition## Documentation
Check our wiki for a more in-depth documentation: https://github.com/rows/automata/wiki## Super quick start:
```
dart pub add automataor
flutter pub add automata
``````dart
import 'package:automata/automata.dart';class Inactive extends AutomataState {}
class Active extends AutomataState {}
class OnToggle extends AutomataEvent {}final machine = StateMachine.create(
(g) => g
..initial()
..state(
builder: (g) => g..on()
)
..state(
builder: (g) => g..on()
),
onTransition: (e, value) => print(
'''
## Transition::
Received Event: $e
Value: $value
''',
),
);machine.send(OnToggle());
```## Credits
While developing this packages we were heavily inspired by [Tinder's StateMachine](https://github.com/Tinder/StateMachine), [Stately's XState](https://github.com/statelyai/xstate) and the [SCXML specification](https://www.w3.org/TR/scxml).