local u=require(script.Parent.prettyPrint)local q={outputFunction=print}function q.middleware(l,r)return function(P)local y=l(P)q.outputFunction(("\065\099\116\105\111\110 \100\105\115\112\097\116\099\104\101\100\058 \037\115\n\083\116\097\116\101 \099\104\097\110\103\101\100 \116\111\058 \037\115"):format(u(P),u(r:getState())))return y end end return q
-- We want to be able to override outputFunction in tests, so the shape of this
-- module is kind of unconventional.
--
-- We fix it this weird shape in init.lua.
local prettyPrint = require(script.Parent.prettyPrint)

local loggerMiddleware = {
	outputFunction = print,
}

function loggerMiddleware.middleware(nextDispatch, store)
	return function(action)
		local result = nextDispatch(action)

		loggerMiddleware.outputFunction(("Action dispatched: %s\nState changed to: %s"):format(prettyPrint(action), prettyPrint(store:getState())))

		return result
	end
end

return loggerMiddleware
