Skip to content

Commit

Permalink
fix a test, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Nov 3, 2021
1 parent e0c44d1 commit 39d8e66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const devtools =

export type StoreApiWithSubscribeWithSelector<T extends State> = Omit<
StoreApi<T>,
'subscribe'
'subscribe' // FIXME remove omit in v4
> & {
subscribe: {
(listener: StateListener<T>): () => void
Expand All @@ -233,7 +233,7 @@ export const subscribeWithSelector =
(
set: CustomSetState,
get: CustomGetState,
api: Omit<CustomStoreApi, 'subscribe'> &
api: Omit<CustomStoreApi, 'subscribe'> & // FIXME remove omit in v4
StoreApiWithSubscribeWithSelector<S>
): S => {
const origSubscribe = api.subscribe as Subscribe<S>
Expand All @@ -255,7 +255,11 @@ export const subscribeWithSelector =
}
return origSubscribe(listener)
}) as any
const initialState = fn(set, get, api as CustomStoreApi)
const initialState = fn(
set,
get,
api as CustomStoreApi // FIXME can remove in v4?
)
return initialState
}

Expand Down
3 changes: 1 addition & 2 deletions tests/middlewareTypes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ describe('counter state spec (double middleware)', () => {
persist(
(set, get) => ({
count: 1,
inc: () =>
set({ count: get().count + 1 }, false /* TODO , 'inc' */),
inc: () => set({ count: get().count + 1 }, false, 'inc'),
}),
{ name: 'count' }
),
Expand Down

0 comments on commit 39d8e66

Please sign in to comment.