Skip to content
Myr

immer.js.flow

This file

Path

src/immer.js.flow

47 lines · 2.0 KiB

Last changed by

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

History of this file

Take it

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

lines 1–2why, one step back
1// @flow
2

Added flow types, implements #34Michel Weststratebefore adoption737e556

lines 3–16why, one step back
3declare export function extendShallowObservable(target: any): any
45/**6 * Immer takes a state, and runs a function against it.7 * That function can freely mutate the state, as it will create copies-on-write.8 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned9 *10 * If only one argument is passed, this is interpreted as the recipe, and will create a curried function that will execute the recipe11 * any time it is called with a base state12 *13 * @param currentState - the state to start with14 * @param thunk - function that receives a proxy of the current state as first argument and which can be freely modified15 * @returns The next state: a new state, or the current state if nothing was modified16 */

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

line 17why, one step back
17declare export default function produce<S>(

Added flow types, implements #34Michel Weststratebefore adoption737e556

lines 18–21why, one step back
18 currentState: S,
19 recipe: (draftState: S) => void20): S21// curried invocations

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

line 22why, one step back
22declare export default function produce<S, A, B, C>(

Added flow types, implements #34Michel Weststratebefore adoption737e556

lines 23–24why, one step back
23 recipe: (draftState: S, a: A, b: B, c: C) => void
24): (currentState: S, a: A, b: B, c: C) => S

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

line 25why, one step back
25declare export default function produce<S, A, B>(

Added flow types, implements #34Michel Weststratebefore adoption737e556

lines 26–27why, one step back
26 recipe: (draftState: S, a: A, b: B) => void
27): (currentState: S, a: A, b: B) => S

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

line 28why, one step back
28declare export default function produce<S, A>(

Added flow types, implements #34Michel Weststratebefore adoption737e556

lines 29–30why, one step back
29 recipe: (draftState: S, a: A) => void
30): (currentState: S) => S

Merge pull request #85 from marcins/issue-80/fix-flow-typesMichel Weststratebefore adoption4d9d4d8

line 31why, one step back
31declare export default function produce<S>(

Added flow types, implements #34Michel Weststratebefore adoption737e556

lines 32–47why, one step back
32 recipe: (draftState: S, ...extraArgs: any[]) => void
33): (currentState: S, ...extraArgs: any[]) => S3435/**36 * Automatically freezes any state trees generated by immer.37 * This protects against accidental modifications of the state tree outside of an immer function.38 * This comes with a performance impact, so it is recommended to disable this option in production.39 * It is by default enabled.40 */41declare export function setAutoFreeze(autoFreeze: boolean): void4243/**44 * Manually override whether proxies should be used.45 * By default done by using feature detection46 */47declare export function setUseProxies(useProxies: boolean): void