InitialMachine.fromTree constructor

InitialMachine.fromTree(
  1. FutureOr<StateTreeBuilder> create(
    1. TransitionContext transCtx
    ), {
  2. String? label,
  3. String? logName,
})

Constructs an InitialMachine that will create and start a nested state machine using the StateTreeBuilder produced by the create function.

Implementation

factory InitialMachine.fromTree(
  FutureOr<StateTreeBuilder> Function(TransitionContext transCtx) create, {
  String? label,
  String? logName,
}) {
  return InitialMachine._(
    (ctx) {
      return create(ctx).bind((treeBuilder) {
        return TreeStateMachine(treeBuilder, logName: logName);
      });
    },
    true,
    true,
    label,
  );
}