From 8544c2b9b5993de54d299ec8cbf4443b721af029 Mon Sep 17 00:00:00 2001 From: James Onnen Date: Tue, 3 Dec 2024 13:32:16 -0800 Subject: [PATCH] feat: Return a cleanup method, even when amount is 0 --- .../src/Shared/ObservableCountingMap.lua | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/observablecollection/src/Shared/ObservableCountingMap.lua b/src/observablecollection/src/Shared/ObservableCountingMap.lua index 2950c6d309..32ed5c55f6 100644 --- a/src/observablecollection/src/Shared/ObservableCountingMap.lua +++ b/src/observablecollection/src/Shared/ObservableCountingMap.lua @@ -271,18 +271,10 @@ end ]=] function ObservableCountingMap:Set(key, amount) local current = self:Get(key) - if current == amount then - return - end - if current < amount then self:Add(-(amount - current)) - return - elseif current == amount then - return - else + elseif current > amount then self:Add(current - amount) - return end end @@ -298,7 +290,9 @@ function ObservableCountingMap:Add(key, amount) amount = amount or 1 if amount == 0 then - return + return function() + + end end local oldValue = self._map[key]