/** * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2020-08-25 23:27:28 * @modify date 2020-08-25 23:46:32 * @desc [description] */ import { getSingleton } from "../helpers/singletonMethod"; import { ICommunicationInterface } from './nopeDispatcher'; import { IExportMethodToDispatcherParameters, IExportPropertyToDispatcherParameters } from "./nopeDispatcherDecorators"; import { getDispatcher } from "./getDispatcher"; /** * Returns a Dispatcher. * @param communicator */ export function getLinkedDispatcher(communicator: ICommunicationInterface) { const container = getSingleton('nopeBackendDispatcher.methodContainer', () => { return { methods: new Map Promise, options: IExportMethodToDispatcherParameters }>(), parameters: new Map Promise, options: IExportPropertyToDispatcherParameters }>() } }); const dispatcher = getDispatcher(communicator); for (const [uri, settings] of container.instance.methods.entries()) { dispatcher.registerFunction(settings.callback, { id: uri }) } return dispatcher; }