decorate()

in src/app/debounceDecorator.js [6:21]


  decorate(call) {
    return new Promise((resolve, reject) => {
      if (this.lastTimeOut) {
        clearTimeout(this.lastTimeOut);
        this.reject && this.reject(DebounceDecorator.CANCEL_PROMISE_REASON);
      }
      this.reject = reject;
      this.lastTimeOut = setTimeout(() => {
        resolve(call());
      }, DebounceDecorator.REQUEST_DELAY);
    }).catch(reason => {
      if (reason !== DebounceDecorator.CANCEL_PROMISE_REASON) {
        throw reason;
      }
    });
  }