MessageHandlerBuilder<M> class
Provides methods for describing how a state behaves in response to a message of type M.
A MessageHandlerBuilder is provided to the build callback provided to StateBuilder.onMessage, and is used to describe how messages of a particular type are handled by a state.
class MyMessage {}
var state1 = StateKey('s1');
var state2 = StateKey('s2');
var builder = StateTreeBuilder(initialState: state1);
builder.state(state1, (b) {
// Describe how state responds to MyMessage messages
b.onMessage<MyMessage>((b) => b.goTo(state2));
});
Properties
-
act
→ MessageActionBuilder<
M> -
A MessageActionBuilder that can be used to specify actions that should take place when
handling messages.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
action(
_MessageAction< M> action, [ActionResult actionResult = ActionResult.handled]) → void -
enterChannel<
P> (Channel< P> channel, FutureOr<P> payload(MessageContext msgCtx, M msg), {bool reenterTarget = false}) → void -
goTo(
StateKey targetState, {TransitionHandler? transitionAction, bool reenterTarget = false, FutureOr< Object?> payload(MessageContext ctx, M message)?, _MessageAction<M> ? action, String? label}) → void -
Indicates that a transition to
targetStateshould occur. -
goToSelf(
{TransitionHandler? transitionAction, _MessageAction< M> ? action, String? label}) → void - Indicates that the message has been handled, and that a self transition should occur.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
stay(
{_MessageAction< M> ? action}) → void - Indicates that the message has been handled, and no state transition should occur.
-
toString(
) → String -
A string representation of this object.
inherited
-
unhandled(
{_MessageAction< M> ? action}) → void - Indicates that the message has not been handled, and the message should be dispatched to ancestor states for processing.
-
when(
FutureOr< bool> condition(MessageContext msgCtx, M msg), void buildTrueHandler(MessageHandlerBuilder<M> ), {String? label}) → MessageHandlerWhenBuilder<M> -
whenResult<
T> (FutureOr< Result< result(MessageContext msgCtx, M msg), void buildTrueHandler(ContinuationMessageHandlerBuilder<T> >M, T> ), {String? label}) → MessageHandlerWhenResultBuilder<M, T> -
whenWith<
T> (FutureOr< T> context(MessageContext ctx, M message), FutureOr<bool> condition(MessageContext msgCtx, M msg, T ctx), void buildTrueHandler(MessageHandlerBuilder<M> ), {String? label}) → MessageHandlerWhenWithContextBuilder<M, T>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited