UNPKG

redux-promise-thunk

Version:

Thunk generator to dispatch Flux-Standard-Action in each phase of promise

26 lines (20 loc) 441 B
"use strict"; exports.__esModule = true; exports.loopAsync = loopAsync; function loopAsync(turns, work, callback) { var currentTurn = 0; var isDone = false; function done() { isDone = true; callback.apply(this, arguments); } function next() { if (isDone) return; if (currentTurn < turns) { work.call(this, currentTurn++, next, done); } else { done.apply(this, arguments); } } next(); }