UNPKG

@intuitionrobotics/ts-common

Version:
21 lines 801 B
import {} from "../utils/types.js"; export class Dispatcher { static modulesResolver; method; filter; constructor(method) { this.method = method; this.filter = (listener) => !!listener[this.method]; } dispatchModule(...p) { const listeners = Dispatcher.modulesResolver(); // @ts-expect-error TS struggles with this dynamic typing return listeners.filter(this.filter).map((listener) => listener[this.method](...p)); } async dispatchModuleAsync(...p) { const filtered = Dispatcher.modulesResolver().filter(this.filter); // @ts-expect-error TS struggles with this dynamic typing return Promise.all(filtered.map(async (listener) => listener[this.method](...p))); } } //# sourceMappingURL=dispatcher.js.map