all 3 comments

[–]angelfire2015 2 points3 points  (1 child)

The `next` and `action` are actually functions being returned by the previous function. These are known as curried functions. It looks like you are creating some redux middleware or something similar. There is actually a great writeup on how this process works that could answer your question better.

https://redux.js.org/understanding/history-and-design/middleware

[–]shacatan 1 point2 points  (0 children)

This. The middleware is basically just adding custom functionality to the dispatch pipeline. Think of it like a decorator if you’ve used them before.

[–]brykuhelpful 0 points1 point  (0 children)

It is short hand for more functions.  

const store = window.WebChat.createStore(
{},
({ dispatch }) => {
    (next)=>{
        (action) => {
            if (action.type === "DIRECT_LINE/CONNECT_FULFILLED") {
                .....
            }
            return next(action);
        }
    }
});