How to add data to Rodux store?

hello, im currently trying to experiment with rodux. One thing im stuck on is adding data to the store. I tried looking at the docs but those didn’t help much.

This is my code:

local rodux = require(game.ReplicatedStorage:WaitForChild("Rodux"))

local data = {
	['coins'] = 2
}

local dataReducer = function(state, action)
	print(state, action)
	if action.type == "coin" then
		print(action.coins)
	end
end


local store = rodux.Store.new(dataReducer)

local action = {
	type = "coin",
	coins = 20
}

--- i want to add the 2nd table to rodux store

any help is appreciated thanks!

found a fix.

Basically you need to add middleware to the store then send the data using the :dispatch function from the store.

local rodux = require(game.ReplicatedStorage:WaitForChild("Rodux"))

local data = {
	['coins'] = 2
}

local dataReducer = function(state, action)
	if action.type == "coins" then
		print(action.coins)
		
		return action.coins
	end
end


local store = rodux.Store.new(dataReducer,nil, {
	rodux.thunkMiddleware})

store:dispatch({
	type = "coins",
	coins = 20
})