Skip to content

Revamp EventDispatcher component#236

Merged
Blacksmoke16 merged 13 commits intomasterfrom
as-event-dispatcher
Dec 12, 2022
Merged

Revamp EventDispatcher component#236
Blacksmoke16 merged 13 commits intomasterfrom
as-event-dispatcher

Conversation

@Blacksmoke16
Copy link
Member

@Blacksmoke16 Blacksmoke16 commented Dec 11, 2022

  • (breaking) Revamp Athena::EventDispatcher to be more better
    • Drop self.subscribed_events in favor of a new AEDA::AsEventListener annotation
    • Listeners are not longer automagically registered with the dispatcher
    • Dispatcher's constructor no longer accepts an array of listener instances
    • Rename/alter API of most dispatcher interface methods (name, parameters, return types)
    • Listeners are now represented as an AED::Callable instance, as returned from the dispatcher
    • Remove EventListenerType alias
    • Remove SubscribedEvents alias
    • Remove EventListener struct
    • AED::Event is now abstract
    • Remove AED.create_listener
    • Add AED::GenericEvent for simple use cases
  • Update framework component to be compatible with new dispatcher changes
    • Leverage the annotation
    • Rename methods to be more clear on what they're doing
    • Remove unused dispatcher parameter from each listener method
    • Revamp how listener services are added to the dispatcher such that they are now fully lazy. I.e. only instantiated if that event is emitted

First pass at making listeners lazy
Add helper method to create a callable proc for a given event
Remove events from sorted hash
Introduce new wrapper type to avoid exposing raw procs
Make the event listener interface overload return `nil` since it adds multiple callables
More docs
Break `#has_listeners?` into two overloads
@Blacksmoke16 Blacksmoke16 marked this pull request as ready for review December 12, 2022 00:14
@Blacksmoke16 Blacksmoke16 merged commit a044d1f into master Dec 12, 2022
@Blacksmoke16 Blacksmoke16 deleted the as-event-dispatcher branch December 12, 2022 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant