Skip to content

Commit

Permalink
Export thunk and withExtraArgument as named values and remove defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jan 18, 2023
1 parent b96589c commit 587a85b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function createThunkMiddleware<
return middleware
}

const thunk = createThunkMiddleware() as ThunkMiddleware & {
export const thunk = createThunkMiddleware() as ThunkMiddleware & {
withExtraArgument<
ExtraThunkArg,
State = any,
Expand All @@ -46,8 +46,6 @@ const thunk = createThunkMiddleware() as ThunkMiddleware & {
): ThunkMiddleware<State, BasicAction, ExtraThunkArg>
}

// Attach the factory function so users can create a customized version
// Export the factory function so users can create a customized version
// with whatever "extra arg" they want to inject into their thunks
thunk.withExtraArgument = createThunkMiddleware

export default thunk
export const withExtraArgument = createThunkMiddleware
4 changes: 2 additions & 2 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import thunkMiddleware from '../src/index'
import { thunk as thunkMiddleware, withExtraArgument } from '../src/index'

describe('thunk middleware', () => {
const doDispatch = () => {}
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('thunk middleware', () => {
it('must pass the third argument', done => {
const extraArg = { lol: true }
// @ts-ignore
thunkMiddleware.withExtraArgument(extraArg)({
withExtraArgument(extraArg)({
dispatch: doDispatch,
getState: doGetState
})()((dispatch: any, getState: any, arg: any) => {
Expand Down

0 comments on commit 587a85b

Please sign in to comment.