Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined Silos do not remove keys correctly. #97

Open
Y1195 opened this issue Jun 2, 2022 · 0 comments
Open

Combined Silos do not remove keys correctly. #97

Y1195 opened this issue Jun 2, 2022 · 0 comments

Comments

@Y1195
Copy link

Y1195 commented Jun 2, 2022

When dispatching SiloUtil.None in a combined silo, it does not remove the value from the state.

Single Silo:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Silo = require(ReplicatedStorage.Packages.Silo)
local SiloUtil = require(ReplicatedStorage.Packages._Index["[email protected]"].silo.Util)

local initialState = {
	myValue = 123,
}

local mySilo = Silo.new(initialState, {
	Set = function(state, action)
		state.myValue = action.value
	end,
})

mySilo:Watch(function(state)
	return state
end, function(objects)
	print(objects)
end)

task.wait(1)

print("Set Empty")
mySilo:Dispatch(mySilo.Actions.Set({
	value = SiloUtil.None
}))

Final Output: {}


Combined Silo:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Silo = require(ReplicatedStorage.Packages.Silo)
local SiloUtil = require(ReplicatedStorage.Packages._Index["[email protected]"].silo.Util)

local initialState = {
	myValue = 123,
}

local mySilo = Silo.new(initialState, {
	Set = function(state, action)
		state.myValue = action.value
	end,
})

local MAIN = Silo.combine({
	mySilo = mySilo,
})

MAIN:Watch(function(state)
	return state.mySilo
end, function(objects)
	print(objects)
end)

task.wait(1)

print("Set Empty")
MAIN:Dispatch(mySilo.Actions.Set({
	value = SiloUtil.None
}))

Final Output: {myValue = 123}
Expected output: {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant