Privileged helper for system proxy (#796)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gregory SchierandClaude Opus 5.5 authored and GitHub committed 2026-10-30 00:41:00 -07:00
1 parent 4d38a482f6
commit f7aea62c07
33 files changed
+3536 -176

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
/**
* An unsubscribe for a subscription that is still being set up. Called before the setup
* resolves, it unsubscribes as soon as it does; `active` says whether to still deliver events.
*/
export function unsubscribeWhenReady(subscription: Promise<() => void>): {
unsubscribe: () => void;
active: () => boolean;
} {
let unsub: (() => void) | null = null;
let cancelled = false;
subscription
.then((fn) => {
if (cancelled) fn();
else unsub = fn;
})
.catch(console.error);
return {
unsubscribe: () => {
cancelled = true;
unsub?.();
unsub = null;
},
active: () => !cancelled,
};
}