Return onCancel callback from the executor
Opened this issue · 0 comments
Filyus commented
It seems to me that instead of
executor(resolve, reject, (onCancel) => {
internals.onCancelList.push(onCancel);
})
const promise = new CancelablePromise((resolve, reject, onCancel) => {
onCancel(() => {
//cancel code
});
});
it is a bit easier to use such code
const onCancel = executor(resolve, reject);
internals.onCancelList.push(onCancel);
const promise = new CancelablePromise((resolve, reject) => {
return () => {
//cancel code
};
});