Repository navigation
Improve event handling and the eventing API - #102
Open
KlaasWhite wants to merge 1 commit into
Open
KlaasWhite wants to merge 1 commit into
KlaasWhite wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Disposed named channels remain permanently retained, allowing memory growth when mods repeatedly create transient channel names.
1 open issue
What changed in this PR
This PR replaces event mediation with a typed event bus for cross-mod messaging, supporting multiple publishers and subscriptions created before publishers.
Changes:
- Introduces
IEventBuswith default and named channels, without requiring a marker interface. - Reworks publisher and subscription handles and removes parallel publishing.
- Updates modding guides and navigation for the new API.
| File | Description |
|---|---|
| StarMap.Core/StarMapCore.cs | Registers the new event bus service. |
| StarMap.Core/Services/Mediator.cs | Implements typed buses, named channels, and disposable handles. |
| StarMap.Core/API/MediationService.cs | Removes the old mediation wrapper. |
| StarMap.Core/API/EventBus.cs | Adds the event bus service wrapper. |
| StarMap.API/Services/IMediationService.cs | Removes the old service interface. |
| StarMap.API/Services/IEventBus.cs | Defines publisher and subscription operations. |
| StarMap.API/Mediation/ISubscription.cs | Removes the constrained subscription interface. |
| StarMap.API/Mediation/IStarMapEvent.cs | Removes the event marker interface. |
| StarMap.API/Mediation/IEventPublisher.cs | Removes the previous publisher contract. |
| StarMap.API/Events/ISubscription.cs | Adds an unconstrained subscription contract. |
| StarMap.API/Events/IEventPublisher.cs | Adds the synchronous publisher contract. |
| mkdocs.yml | Links navigation to the event bus guide. |
| docs/modding/services.md | Updates the event service listing. |
| docs/modding/mod-services.md | References the new built-in service. |
| docs/modding/lifecycle.md | Updates injectable services and guide links. |
| docs/modding/index.md | Links to the event bus guide. |
| docs/modding/event-mediation.md | Removes the obsolete mediation guide. |
| docs/modding/event-bus.md | Documents publishing, subscriptions, channels, and delivery. |
| docs/modding/dependencies.md | Updates shared message contract requirements. |
| docs/modding/constructor-injection.md | Lists IEventBus as an injectable service. |
Review effort: Balanced
| public EventBus<T> GetNamedBus(string eventName) | ||
| { | ||
| handler.Invoke(message); | ||
| return _namedBusses.GetOrAdd(eventName, (_) => new NamedEventBus<T>()); |
Member
Author
There was a problem hiding this comment.
Currently busses remain in memory forever to reduce any thread risk coming with disposing and creation. In a future update this can be added to reduce memory, but the retained memory should be minimal. With no disposal, busses cannot be disconnected so no issues should arise
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.