I have a function where I do this :
this._getContainerData().then((data) => {
this.__getIndexes(idx).forEach((indexVisible, index) => {
this.containerData[indexVisible] = data[index]
});
if (this.horizontalRailIndex === idx) {
this.container._setData(this.context);
}
});
this._getContainerData()
returns a promise and it's called multiple times. I want to check if this promise takes more than 1000ms - if so cancel it or return an empty promise. I have a class called CancelablePromise
that I can import and use like : new CancelablePromise
and it does have a cancel function. If you have any other suggestions I will be glad to hear them.