Skip to content

Conversation

@DamianSuess
Copy link
Contributor

Details

Adds the ability to subscribe to EventAggregator message types from the RegisterState and RegisterSubState methods.

    machine
      .AddContext(ctxProperties)
      .RegisterState<State1>(StateId.State1, StateId.State2, subscriptionTypes: [typeof(UnlockResponse)])
      // ...
      .RegisterSubState<State2_Sub2_Sub1>(StateId.State2_Sub2_Sub1, parentStateId: StateId.State2_Sub2, onSuccess: StateId.State2_Sub2_Sub2, subscriptionTypes: [typeof(UnlockResponse), typeof(CloseResponse)])

The is the equivalent to subscribing from the State itself:

public class State1() : ICommandState<StateId>
{
  public override IReadOnlyCollection<Type> SubscribedMessageTypes =>
    [ typeof(UnlockResponse) ];

  public Task OnEntering(Context<StateId> context) => Task.CompletedTask;

  public Task OnEnter(Context<StateId> context) => Task.CompletedTask;

  public Task OnMessage(Context<StateId> context, object message) { ... }

  public Task OnTimeout(Context<StateId> context) { ... }

  public Task OnExit(Context<StateId> context) => Task.CompletedTask;
}

Linked To Issue/Feature

@DamianSuess DamianSuess linked an issue Jan 13, 2026 that may be closed by this pull request
@DamianSuess DamianSuess added this to the v2.3 milestone Jan 13, 2026
@DamianSuess DamianSuess self-assigned this Jan 13, 2026
@DamianSuess DamianSuess added the enhancement New feature or request label Jan 13, 2026
@DamianSuess DamianSuess merged commit f447c7d into develop Jan 13, 2026
1 check passed
@DamianSuess DamianSuess deleted the feature/89-RegisterState-EvtAggrSubscriptions branch January 13, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2.3] RegisterState Parameter for Message Type Subscriptions

2 participants