Skip to content

Use EventAggregator instead of callbacks to react to events from the API

username-removed-1496206 requested to merge ref-ea-usage into master

Created by: Jenselme

This PR is aimed at standardizing how the application reacts to event. We used to rely on events for the EventAggregator for some actions but we used callbacks registered in the API to react to the game events. We now always rely on the EventAggretor. This component becomes the central place to register and publish events.

In order to ease the management (mostly disposable to reduce memory usage) of many subscriptions, we create a EventAggregatorSubscriptions utility class which can tracks subscriptions of a component and dispose of all of them at once.

Contents

  • ref(api): remove registration of callbacks on errors

    • Use the EventAggregator with the aot:api:error signal instead
    • Remove dependency on Api in Game
    • Add some logic to EventAgregatorStub to ease testing
    • Test logic of EventAgregatorStub
  • ref(api): remove registration of callbacks on WS messages

    • Remove callbacks (de)registration logic
    • Use EventAggregator instead
    • Dispose of subscriptions on deactivate or unbind
  • ref(game,trumps): dispose of EventAggregartor subscriptions

  • fix(tests): correcty typo in name EventAgregatorStub

  • ref(utils): improve loop over subsciptions in EventAggregatorSubscriptions

Merge request reports