Skip to content

预览 cms #1

Description

@dzylikecode

下面本质是一个动力学差分方程,也可以说是状态机

@freezed
sealed class S with _$S {
  const factory S.s0() = S0;
  const factory S.s1() = S1;
}

@freezed
sealed class A with _$A {
  const factory A.a0() = A0;
  const factory A.a1() = A1;
}

@CmsGraph()
class M extends Cms<S, A> {
  M() : super(.s0());
  // dart format off
  @override
  Future<S?> kernel(S s, A a) async => switch ((s, a)) {
    (S0 _, A0 _) => () {
                      if (Random().nextBool()) return S.s1();
                      return S.s1();
                    }(),
    (S1 _, A1 _) => .s0(),
    _ => undefined(s, a),
  };
  // dart format on
}

我想对其积分,看到其演化。通过 @CmsGraph() 来做到

xstate 画出了图像

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions