We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'd like to console.log each time an action is being called, with the passed params.
console.log
For example:
increment, 1 decrement, 2 setName, foo
etc.
This is my middleware:
const logger: TLoggerImpl = (config, logger) => (set, get, api) => { const originalConfig = config(set, get, api); const newActions = Object.fromEntries( Object.entries(originalConfig).map(([actionName, actionFn]) => { let enhancedFn = actionFn; if (typeof actionFn === "function") { enhancedFn = (...args: unknown[]) => { const ret = actionFn(...args); logger(actionName, args); return ret; }; } return [actionName, enhancedFn]; }), ); return { ...originalConfig, ...newActions }; };
It works when I wrap my store before zundo, but it's not ideal because I'm using debounce with handleSet.
zundo
handleSet
I've seen a suggestion to use wrapTemporal here #184.
wrapTemporal
So I did:
wrapTemporal: (storeInitializer) => logger(storeInitializer, (fnName, fnArgs) => { console.log(`${fnName} called with ${JSON.stringify(fnArgs)}`); }),
But it only catches _handleSet with old state and new state.
_handleSet
Is there a way to do it?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'd like to
console.log
each time an action is being called, with the passed params.For example:
increment, 1
decrement, 2
setName, foo
etc.
This is my middleware:
It works when I wrap my store before
zundo
, but it's not ideal because I'm using debounce withhandleSet
.I've seen a suggestion to use
wrapTemporal
here #184.So I did:
But it only catches
_handleSet
with old state and new state.Is there a way to do it?
The text was updated successfully, but these errors were encountered: