Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Enhancement] Add extensions methods to dynamically add and subscribe to integration event handlers #2132

Open
ErikHakobyan opened this issue Jun 22, 2023 · 0 comments

Comments

@ErikHakobyan
Copy link

Now
builder.Services.AddTransient<ProductPriceChangedIntegrationEventHandler>();
builder.Services.AddTransient<OrderStatusChangedToShippedIntegrationEventHandler>();
builder.Services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>();

var eventBus = app.Services.GetRequiredService<IEventBus>();
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
eventBus.Subscribe<OrderStatusChangedToShippedIntegrationEvent, OrderStatusChangedToShippedIntegrationEventHandler>();
eventBus.Subscribe<OrderStatusChangedToPaidIntegrationEvent, OrderStatusChangedToPaidIntegrationEventHandler>();

After
builder.Services.AddIntegrationEventHandlers(Assembly.GetExecutingAssembly());

app.SubscribeIntegrationEventHandlers(Assembly.GetExecutingAssembly());

I have already implemented and tested this functionality, which works fine and removes unnecessary lines of code from the startup.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant