RenderJS Home RenderJS

    Do not use Promise.prototype.then()

    • Last Update:2020-06-05
    • Version:001
    • Language:en

    Do not use Promise.prototype.then()

    renderJS uses internally Nexedi's fork of RSVP, which allows to cancel promise.

    Using the .then method creates a new Promise object, preventing to cancel the predecessor promises.

    Use RSVP.Queue() promise and chain asynchronous call with the .push method.

    Good example:

    return new RSVP.Queue(RSVP.delay(10))
      .push(function () {
        return "OK";
      });
    

    Bad example:

    return RSVP.delay(10)
      .then(function () {
        return "OK";
      });