endlich 0.1.0-beta.2
endlich: ^0.1.0-beta.2 copied to clipboard
Finite State Machine
example/lib/example.dart
library example;
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:endlich/endlich.dart';
part 'example.g.dart';
part 'example.freezed.dart';
@Endlich()
@freezed
class TestState with _$TestState {
@Endlich.initial()
@Endlich.state(effect: 'inFoo')
factory TestState.foo(
int count,
@Endlich.event(Bar) void Function(int incr) next,
) = Foo;
@Endlich.state(effect: 'inBar')
factory TestState.bar(
int count,
@Endlich.event(Baz) void Function(int incr) next,
) = Bar;
@Endlich.state(effect: 'inBaz')
factory TestState.baz(
int count,
@Endlich.event(Foo) void Function(int incr) next,
) = Baz;
}