Skip to content

Commit

Permalink
feature: skip render this will allow user to update the store without… (
Browse files Browse the repository at this point in the history
#134)

* feature: skip render this will allow user to update the store without trigger the context update

* 4.6.0-next.0

* fix type error

* 4.6.0-next.1
  • Loading branch information
bluebill1049 authored Sep 1, 2022
1 parent bc10b65 commit d0f65c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"files": [
"dist"
],
"version": "4.5.0",
"version": "4.6.0-next.1",
"main": "dist/little-state-machine.js",
"module": "dist/little-state-machine.es.js",
"unpkg": "dist/little-state-machine.umd.js",
Expand Down
4 changes: 2 additions & 2 deletions src/stateMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const actionTemplate =
setState: React.Dispatch<React.SetStateAction<GlobalState>>,
callback: TCallback,
) =>
(payload: Parameters<TCallback>[1]) => {
(payload: Parameters<TCallback>[1], options?: { skipRender: boolean }) => {
if (process.env.NODE_ENV !== 'production') {
window[STORE_ACTION_NAME] = callback.name;
}
Expand All @@ -52,7 +52,7 @@ const actionTemplate =
);
}

setState(storeFactory.state);
(!options || !options.skipRender) && setState(storeFactory.state);
storeFactory.options.persist !== PERSIST_BEFORE_UNLOAD &&
storeFactory.saveStore();
};
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ActionsOutput<
TCallback extends AnyCallback,
TActions extends AnyActions<TCallback>,
> = {
[K in keyof TActions]: (payload?: Parameters<TActions[K]>[1]) => void;
[K in keyof TActions]: (payload?: Parameters<TActions[K]>[1], options?: { skipRender: boolean }) => void;
};

export type StateMachineContextValue = {
Expand Down

0 comments on commit d0f65c5

Please sign in to comment.