@fbltd/async
Version:
Miscellaneous async utils
28 lines (27 loc) • 717 B
JavaScript
import { PromiseConfiguration } from "../promise-configuration.js";
import { symAI } from "../constants.js";
export class DependencyStream {
owner;
selfDispose = new PromiseConfiguration();
iterator;
get isDisposed() {
return this.iterator.isDisposed;
}
constructor(owner) {
this.owner = owner;
this.selfDispose = new PromiseConfiguration();
this.iterator = owner[symAI]({ externalDispose: this.selfDispose });
}
[symAI]() {
return {
next: () => {
return this.iterator.next();
}
};
}
dispose() {
if (this.isDisposed)
return;
this.selfDispose.resolve();
}
}