From fa97e23006c9f572db200ec5c61522a91d7cffa4 Mon Sep 17 00:00:00 2001 From: Oliver Biwer Date: Wed, 7 Oct 2020 17:46:19 +0000 Subject: [PATCH] fixing #200 (UnregisterAll for AtomEventBase) UnregisterAll did not unregister for listeners of OnEventNoValue. --- Packages/Core/Runtime/Events/AtomEvent.cs | 5 +++-- Packages/Core/Runtime/Events/AtomEventBase.cs | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Packages/Core/Runtime/Events/AtomEvent.cs b/Packages/Core/Runtime/Events/AtomEvent.cs index 6c68ad2a..0c3e5e13 100644 --- a/Packages/Core/Runtime/Events/AtomEvent.cs +++ b/Packages/Core/Runtime/Events/AtomEvent.cs @@ -26,7 +26,7 @@ namespace UnityAtoms protected event Action _onEvent; /// - /// The event replays the specified number of old values to new subscribers. Works like a ReplaySubject in Rx. + /// The event replays the specified number of old values to new subscribers. Works like a ReplaySubject in Rx. /// [SerializeField] [Range(0, 10)] @@ -97,8 +97,9 @@ namespace UnityAtoms /// /// Unregister all handlers that were registered using the `Register` method. /// - public void UnregisterAll() + public override void UnregisterAll() { + base.UnregisterAll(); _onEvent = null; } diff --git a/Packages/Core/Runtime/Events/AtomEventBase.cs b/Packages/Core/Runtime/Events/AtomEventBase.cs index 8c71abc6..7fdc1d11 100644 --- a/Packages/Core/Runtime/Events/AtomEventBase.cs +++ b/Packages/Core/Runtime/Events/AtomEventBase.cs @@ -42,6 +42,14 @@ namespace UnityAtoms OnEventNoValue -= del; } + /// + /// Unregister all handlers that were registered using the `Register` method. + /// + public virtual void UnregisterAll() + { + OnEventNoValue = null; + } + /// /// Register a Listener that in turn trigger all its associated handlers when the Event triggers. /// @@ -75,4 +83,4 @@ namespace UnityAtoms } } -} \ No newline at end of file +}