mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-12-04 13:56:23 +01:00
Privileged helper for system proxy (#796)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d38a482f6
commit
f7aea62c07
33 files changed
+3536
-176
No files matched your search
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user