Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
local Store = require(script.Store) | ||
local createReducer = require(script.createReducer) | ||
local combineReducers = require(script.combineReducers) | ||
local loggerMiddleware = require(script.loggerMiddleware) | ||
|
||
return { | ||
Store = Store, | ||
createReducer = createReducer, | ||
combineReducers = combineReducers, | ||
loggerMiddleware = loggerMiddleware, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local indentStr = " " | ||
|
||
local function prettyPrint(t, indent) | ||
indent = indent or 1 | ||
local outputBuffer = { | ||
"{\n" | ||
} | ||
|
||
for key, value in pairs(t) do | ||
local strKey = tostring(key) | ||
|
||
table.insert(outputBuffer, indentStr:rep(indent + 1)) | ||
table.insert(outputBuffer, strKey) | ||
table.insert(outputBuffer, " = ") | ||
|
||
if type(value) == "table" then | ||
table.insert(outputBuffer, prettyPrint(value, indent + 1)) | ||
table.insert(outputBuffer, "\n") | ||
else | ||
table.insert(outputBuffer, tostring(value)) | ||
table.insert(outputBuffer, "; (") | ||
table.insert(outputBuffer, typeof(value)) | ||
table.insert(outputBuffer, ")\n") | ||
end | ||
end | ||
|
||
table.insert(outputBuffer, indentStr:rep(indent)) | ||
table.insert(outputBuffer, "}") | ||
|
||
return table.concat(outputBuffer, "") | ||
end | ||
|
||
local function loggerPlugin(next) | ||
return function(store, action) | ||
print("Action dispatched:", prettyPrint(action)) | ||
next(store, action) | ||
print("State changed to:", prettyPrint(store:getState())) | ||
end | ||
end | ||
|
||
return loggerPlugin |