Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix events not using correct type for dispatching #25

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Matthiee
Copy link
Member

@Matthiee Matthiee commented Dec 7, 2024

This fixes #22


When a redirect factory constructor is used, the Base and Runtime types differ and both have separate handlers registered. For this case, both handlers will be used when dispatching.

mediator.events.on<BaseEvent>().subscribeFunction((e) => checkEvent('base', e));
mediator.events.on<ConcreteEvent>().subscribeFunction((e) => checkEvent('concrete', e));

await mediator.events.dispatch(BaseEvent.concrete());

Both event handlers will be executed with the event having a generic type of BaseEvent and runtime type of ConcreteEvent.

@Matthiee Matthiee added bug Something isn't working enhancement New feature or request Breaking Breaking change in the API labels Dec 7, 2024
@Matthiee Matthiee self-assigned this Dec 7, 2024
Copy link

codecov bot commented Dec 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f535942) to head (0cdef50).

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #25   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines          516       519    +3     
=========================================
+ Hits           516       519    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Matthiee Matthiee force-pushed the feature/dispatch-typing-improvements branch from cce6f5d to 0cdef50 Compare December 7, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Breaking change in the API bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: EventManager Uses Incorrect Compile-Time Generic Type for Event Dispatching
1 participant