From b5a9afecf99de7ec90596bcc9ba84216f3d28831 Mon Sep 17 00:00:00 2001 From: Joe Thompson Date: Sat, 25 Jul 2026 14:26:01 -0400 Subject: [PATCH] Added clear functions to the LocalEventBus --- .../FluffyVoid.EventBus.csproj | 6 ++--- FluffyVoid.EventBus/LocalEventBus.cs | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/FluffyVoid.EventBus/FluffyVoid.EventBus.csproj b/FluffyVoid.EventBus/FluffyVoid.EventBus.csproj index 4014682..5816d87 100644 --- a/FluffyVoid.EventBus/FluffyVoid.EventBus.csproj +++ b/FluffyVoid.EventBus/FluffyVoid.EventBus.csproj @@ -13,10 +13,10 @@ Thread-safe C# event bus framework that allows for subscribing and publishing events in a decoupled method. FluffyVoid FluffyVoid.EventBus - 1.0.4 - 1.0.4 + 1.0.5 + 1.0.5 https://github.com/ashiryn/EventBus - 1.0.4 + 1.0.5 diff --git a/FluffyVoid.EventBus/LocalEventBus.cs b/FluffyVoid.EventBus/LocalEventBus.cs index f0cc0a1..0aa2b22 100644 --- a/FluffyVoid.EventBus/LocalEventBus.cs +++ b/FluffyVoid.EventBus/LocalEventBus.cs @@ -17,7 +17,28 @@ public class LocalEventBus /// threads /// private readonly object _threadLock = new object(); - + /// + /// Clears all events from the event bus, refreshing it for use + /// + public void Clear() + { + lock (_threadLock) + { + _events.Clear(); + } + } + /// + /// Clears all subscribers from a single event + /// + /// The event type to clear from the event bus + public void Clear() + where TEvent : EventArgs + { + lock (_threadLock) + { + _events.Remove(typeof(TEvent)); + } + } /// /// Returns the current count of subscribers for a desired event type /// @@ -38,7 +59,6 @@ public int Count() return count; } - /// /// Publishes an event out to all subscribed listeners ///