nope/lib/dispatcher/getDispatcher.ts
2020-10-15 11:38:59 +02:00

17 lines
616 B
TypeScript

import { getSingleton } from "../helpers/singletonMethod";
import { NopeObservable } from "../observables/nopeObservable";
import { INopeRpcDispatcherOptions } from "../types/communication.interface";
import { nopeDispatcher } from "./nopeDispatcher";
/**
* Function to extract a Singleton Dispatcher
* @param options The provided options for the Dispatcher
*/
export function getRpcDispatcher(options: INopeRpcDispatcherOptions) {
const container = getSingleton('nopeBackendDispatcher.instance', () => {
return new nopeDispatcher(options, () => new NopeObservable());
});
return container.instance
}