MessageActionBuilder<M, D, C> class
Provides methods for describing actions that can be taken while a state handles a message.
A MessageActionBuilder is accessed from the MessageHandlerBuilder.act property.
void onMessage<M>(MessageHandlerContext<M, void, void>) => print('Handling message');
var state1 = StateKey('s1');
var state2 = StateKey('s2');
var builder = StateTreeBuilder(initialState: state1);
builder.state(state1, (b) {
// Calls the onMessage function as a side effect before the transition occurs
b.onMessage<MyMessage>((b) => b.goTo(state2, action: b.act.run(onMessage)));
});
Constructors
- MessageActionBuilder(StateKey _forState, Logger _log)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post<
M2> ({FutureOr< M2> getMessage(MessageHandlerContext<M, D, C> ctx)?, M2? message, String? label}) → MessageActionDescriptor<M, D, C> - Posts a new message to be processed by the state machine while a message is being handled.
-
run(
FutureOr< void> action(MessageHandlerContext<M, D, C> ), {String? label}) → MessageActionDescriptor<M, D, C> -
Runs the
actionwhile a message is being handled. -
schedule<
M2> ({FutureOr< M2> getMessage(MessageHandlerContext<M, D, C> ctx)?, M2? message, Duration duration = Duration.zero, bool periodic = false, String? label}) → MessageActionDescriptor<M, D, C> - Schedules a message to be processed by the state machine while a message is being handled.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateData<
D2> (D2 update(MessageHandlerContext< M, D, C> ctx, D2 data), {StateKey? forState, String? label}) → MessageActionDescriptor<M, D, C> -
Updates state data of type
Dwhile a message is being handled. -
updateOwnData(
D update(MessageHandlerContext< M, D, C> ctx), {StateKey? forState, String? label}) → MessageActionDescriptor<M, D, C>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited