MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / thenIfNotDisposed

Function thenIfNotDisposed

packages/agent-core/src/di/lifecycle.ts:636–648  ·  view source on GitHub ↗
(
  promise: Promise<T>,
  then: (result: T) => void,
)

Source from the content-addressed store, hash-verified

634}
635
636export function thenIfNotDisposed<T>(
637 promise: Promise<T>,
638 then: (result: T) => void,
639): IDisposable {
640 let disposed = false;
641 void promise.then((result) => {
642 if (disposed) return;
643 then(result);
644 });
645 return toDisposable(() => {
646 disposed = true;
647 });
648}
649
650export function thenRegisterOrDispose<T extends IDisposable>(
651 promise: Promise<T>,

Callers 1

lifecycle.test.tsFile · 0.90

Calls 1

toDisposableFunction · 0.85

Tested by

no test coverage detected