All files / src/store promise.js

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