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

use ...args #110

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ export const temporal = (<TState>(

const setState = store.setState;
// Modify the setState function to call the userlandSet function
store.setState = (state, replace) => {
store.setState = (...args) => {
// Get most up to date state. The state from the callback might be a partial state.
// The order of the get() and set() calls is important here.
const pastState = options?.partialize?.(get()) || get();
setState(state, replace);
setState(...args);
curriedHandleSet(pastState);
};

return config(
// Modify the set function to call the userlandSet function
(state, replace) => {
(...args) => {
// Get most up-to-date state. The state from the callback might be a partial state.
// The order of the get() and set() calls is important here.
const pastState = options?.partialize?.(get()) || get();
set(state, replace);
set(...args);
curriedHandleSet(pastState);
},
get,
Expand Down