[Javascript][Deferred] ある条件が満たされるまでループする

More than 1 year has passed since last update.

こちら のDeferred版。jQuery.deferredでも、Javascript標準のPromiseでも使える。

let makeDeferredLoop = (promise, func, args, interval) => {
    (function deferredLoop() {
        promise.then(() => {
            return func(args);
        }).catch(() => {
            setTimeout(deferredLoop, interval, args);
        });
    })();
};
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.