All files / src/store promise.js

100% Statements 8/8
100% Branches 4/4
100% Functions 4/4
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10 118x       32x 32x       8x  
function isPromise (val) {
  return val && typeof val.then === 'function'
}
 
export default function promiseMiddleware ({dispatch}) {
  return (next) => (action) =>
    isPromise(action)
        ? action.then(dispatch)
        : next(action)
}