Skip to content

Commit

Permalink
feat: Return a cleanup method, even when amount is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Quenty committed Dec 3, 2024
1 parent 52a0cf9 commit 8544c2b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/observablecollection/src/Shared/ObservableCountingMap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down

0 comments on commit 8544c2b

Please sign in to comment.