onMessageWithData<M, D2> method
void
onMessageWithData<M, D2>(
- DataStateKey<
D2> ancestorKey, - void build(
- MessageHandlerBuilder<
M, D, D2> b
- MessageHandlerBuilder<
Describes how messages of type M should be handled by this state, when provided ancestor
state data of type D2.
This method can be used when the message handler for a state requires access to state data from one of its ancestor states.
The build function is called with a TransitionHandlerBuilder that can be used to
describe the behavior of the exit transition.
Implementation
void onMessageWithData<M, D2>(DataStateKey<D2> ancestorKey,
void Function(MessageHandlerBuilder<M, D, D2> b) build) {
var builder = MessageHandlerBuilder<M, D, D2>(
key,
(msgCtx) => msgCtx.data(ancestorKey).value,
_log,
null,
);
build(builder);
if (builder.descriptor != null) {
_messageHandlerMap[M] = builder.descriptor!;
}
}