Skip to content
Myr

match vanilla StateCreator type in middleware/subscribeWithSelector (#787)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* match vanilla StateCreator type Match https://github.com/pmndrs/zustand/blob/0ba3c240078cf61792a4b13ff11d774ecca70a0a/src/vanilla.ts#L50-L52 to make subscribeWithSelector more useful with custom states. Ran into this when trying to use subscribeWithSelector with custom middleware that uses immer's WritableDraft on SetState * apply changes for all middleware

authored by Todd Williams · committed by GitHub · parent 1b2560f · Browse files · 3 files+9 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Todd Williams <twilliams5@snapchat.com>
  • Co-authored-by: daishi <daishi@axlight.com>

Diff stats

3 files+9 added−9 removed

  • other:+9 added−9 removed

3 files+9 added−9 removed

modified:src/middleware/devtools.ts+3 added-3 removed
61 unmodified lines
62 * Pass the `name` in an object `{ name: ... }` instead63 */64export function devtools<65 S extends State,66 CustomSetState extends SetState<S>,67 CustomGetState extends GetState<S>,68 CustomStoreApi extends StoreApi<S>66 CustomSetState extends SetState<S> = SetState<S>,67 CustomGetState extends GetState<S> = GetState<S>,68 CustomStoreApi extends StoreApi<S> = StoreApi<S>69>(70 fn: (set: NamedSet<S>, get: CustomGetState, api: CustomStoreApi) => S,71 options?: string72): (
296 unmodified lines
modified:src/middleware/persist.ts+3 added-3 removed
138 unmodified lines
139140export const persist =141 <142 S extends State,143 CustomSetState extends SetState<S>,144 CustomGetState extends GetState<S>,145 CustomStoreApi extends StoreApi<S>143 CustomSetState extends SetState<S> = SetState<S>,144 CustomGetState extends GetState<S> = GetState<S>,145 CustomStoreApi extends StoreApi<S> = StoreApi<S>146 >(147 config: (148 set: CustomSetState,149 get: CustomGetState,
196 unmodified lines
modified:src/middleware/subscribeWithSelector.ts+3 added-3 removed