import { CachedServices } from "../background/service-factories/factory-options"; type Listener = (...args: [...T, CachedServices]) => Promise; export const combine = ( listeners: Listener[], startingServices: CachedServices = {} ) => { return async (...args: T) => { const cachedServices = { ...startingServices }; for (const listener of listeners) { await listener(...[...args, cachedServices]); } }; };