MessageActionBuilder<M> 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>(MessageContext ctx, M message) => 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)));
});
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(MessageContext msgCtx, M msg)?, M2? message, String? label}) → _MessageAction<M> - Posts a new message to be processed by the state machine while a message is being handled.
-
run(
FutureOr< void> action(MessageContext msgCtx, M msg), {String? label}) → _MessageAction<M> -
Runs the
actionwhile a message is being handled. -
schedule<
M2> ({FutureOr< M2 Function()> getMessage(MessageContext msgCtx, M msg)?, M2? message, Duration duration = Duration.zero, bool periodic = false, String? label}) → _MessageAction<M> - 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<
D> (D update(MessageContext msgCtx, M msg, D current), {StateKey? forState, String? label}) → _MessageAction< M> -
Updates state data of type
Dwhile a message is being handled.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited