ReSwift/ReSwift-Thunk

createThunksMiddleware is typo?

yamoridon opened this issue ยท 5 comments

The equivalent of createThunksMiddleware in redux-thunk is createThunkMiddleware. It does not contain 's'. Is this difference intended or typo?

Ah, interesting. createThunkMiddleware does seem to be the more correct spelling.

Suggestion for implementor: Rename the function, add a deprecated typealias for the old spelling.

@yamoridon do you want to open a PR for this?

Hi, I hope you don't mind that I just opened a PR for this, as there was no recent activity on this. ๐Ÿ™‚

Of course not ๐Ÿ™Œ

Hello @mjarvis , I want to customize the createThunkMiddleware function. Is this possible?

I tried to call thunk.body(dispatch, getState), but the body variable was protected.

Can you give me a hand?

public func createThunkMiddleware<State>() -> Middleware<State> {
    return { dispatch, getState in
        return { next in
            return { action in
                switch action {
                case let thunk as Thunk<State>:
                    thunk.body(dispatch, getState)
                default:
                    next(action)
                }
            }
        }
    }
}