Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createCancelSubscription(node: LinkedListNode<() => void>): CancelSubscription {
return CancelSubscription.create(() => {
if (node.detachSelf()) {
node.value = undefined!;
}
});
}
subscribe(onCancellationRequested): CancelSubscription {
let callback = () => onCancellationRequested();
abortSignal.addEventListener("abort", callback);
return CancelSubscription.create(() => {
if (callback && abortSignal) {
abortSignal.removeEventListener("abort", callback);
callback = undefined!;
}
});
}
};