immer.js.flow
This file
Path
src/immer.js.flow
69 lines · 3.1 KiB
Last changed by
Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
History of this fileTake it
Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8
lines 1–2why, one step back1// @flow2Added flow types, implements #34Michel Weststratebefore adoption737e556
lines 3–5why, one step back3/**4 * Immer takes a state, and runs a function against it.5 * That function can freely mutate the state, as it will create copies-on-write.Merge pull request #121 from pkerschbaum/feature/initial-state-for-curry-fnMichel Weststratebefore adoption2cb5496
line 6why, one step back6 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned.Added flow types, implements #34Michel Weststratebefore adoption737e556
line 7why, one step back7 *Merge pull request #121 from pkerschbaum/feature/initial-state-for-curry-fnMichel Weststratebefore adoption2cb5496
lines 8–9why, one step back8 * If the first argument is a function, this is interpreted as the recipe, and will create a curried function that will execute the recipe9 * any time it is called with the current state.Added flow types, implements #34Michel Weststratebefore adoption737e556
lines 10–11why, one step back10 *11 * @param currentState - the state to start withMerge pull request #121 from pkerschbaum/feature/initial-state-for-curry-fnMichel Weststratebefore adoption2cb5496
lines 12–13why, one step back12 * @param recipe - function that receives a proxy of the current state as first argument and which can be freely modified13 * @param initialState - if a curried function is created and this argument was given, it will be used as fallback if the curried function is called with a state of undefinedAdded flow types, implements #34Michel Weststratebefore adoption737e556
lines 14–15why, one step back14 * @returns The next state: a new state, or the current state if nothing was modified15 */Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8
line 16why, one step back16declare export default function produce<S>(Added flow types, implements #34Michel Weststratebefore adoption737e556
line 17why, one step back17 currentState: S,Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 18why, one step back18 recipe: (draftState: S) => S | voidAdded flow types, implements #34Michel Weststratebefore adoption737e556
line 19why, one step back19): SImproved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
line 20why, one step back20// curried invocations with inital stateMerge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8
line 21why, one step back21declare export default function produce<S, A, B, C>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 22why, one step back22 recipe: (draftState: S, a: A, b: B, c: C) => S | void,Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 23–24why, one step back23 initialState: S24): (currentState: S | void, a: A, b: B, c: C) => SMerge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8
line 25why, one step back25declare export default function produce<S, A, B>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 26why, one step back26 recipe: (draftState: S, a: A, b: B) => S | void,Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 27–28why, one step back27 initialState: S28): (currentState: S | void, a: A, b: B) => SMerge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8
line 29why, one step back29declare export default function produce<S, A>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 30why, one step back30 recipe: (draftState: S, a: A) => S | void,Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 31–32why, one step back31 initialState: S32): (currentState: S | void, a: A) => SMerge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8
line 33why, one step back33declare export default function produce<S>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 34why, one step back34 recipe: (draftState: S) => S | void,Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 35–37why, one step back35 initialState: S36): (currentState: S | void) => S37declare export default function produce<S>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 38why, one step back38 recipe: (draftState: S, ...extraArgs: any[]) => S | void,Improved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 39–42why, one step back39 initialState: S40): (currentState: S | void, ...extraArgs: any[]) => S41// curried invocations without inital state42declare export default function produce<S, A, B, C>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 43why, one step back43 recipe: (draftState: S, a: A, b: B, c: C) => S | voidImproved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 44–45why, one step back44): (currentState: S, a: A, b: B, c: C) => S45declare export default function produce<S, A, B>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 46why, one step back46 recipe: (draftState: S, a: A, b: B) => S | voidImproved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 47–48why, one step back47): (currentState: S, a: A, b: B) => S48declare export default function produce<S, A>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 49why, one step back49 recipe: (draftState: S, a: A) => S | voidImproved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 50–51why, one step back50): (currentState: S, a: A) => S51declare export default function produce<S>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 52why, one step back52 recipe: (draftState: S) => S | voidImproved typings as suggested by #109. Improved typings of initialStateMichel Weststratebefore adoptioncf32c52
lines 53–54why, one step back53): (currentState: S) => S54declare export default function produce<S>(Merge pull request #127 from bugzpodder/masterMichel Weststratebefore adoption2546c5a
line 55why, one step back55 recipe: (draftState: S, ...extraArgs: any[]) => S | voidAdded flow types, implements #34Michel Weststratebefore adoption737e556
lines 56–60why, one step back56): (currentState: S, ...extraArgs: any[]) => S57/**58 * Automatically freezes any state trees generated by immer.59 * This protects against accidental modifications of the state tree outside of an immer function.60 * This comes with a performance impact, so it is recommended to disable this option in production.Merge pull request #87 from apostolos/patch-1Michel Weststratebefore adoptiondc5d942
line 61why, one step back61 * By default it is turned on during local development, and turned off in production.Added flow types, implements #34Michel Weststratebefore adoption737e556
lines 62–69why, one step back62 */63declare export function setAutoFreeze(autoFreeze: boolean): void6465/**66 * Manually override whether proxies should be used.67 * By default done by using feature detection68 */69declare export function setUseProxies(useProxies: boolean): void