nope/lib/dispatcher/getDispatcher.ts

17 lines
616 B
TypeScript
Raw Normal View History

2020-08-30 08:25:53 +00:00
import { getSingleton } from "../helpers/singletonMethod";
2020-10-15 09:38:59 +00:00
import { NopeObservable } from "../observables/nopeObservable";
2020-10-13 13:18:25 +00:00
import { INopeRpcDispatcherOptions } from "../types/communication.interface";
import { nopeDispatcher } from "./nopeDispatcher";
2020-08-30 08:25:53 +00:00
/**
* Function to extract a Singleton Dispatcher
* @param options The provided options for the Dispatcher
2020-08-30 08:25:53 +00:00
*/
2020-10-13 13:18:25 +00:00
export function getRpcDispatcher(options: INopeRpcDispatcherOptions) {
2020-08-30 08:25:53 +00:00
const container = getSingleton('nopeBackendDispatcher.instance', () => {
2020-10-15 09:38:59 +00:00
return new nopeDispatcher(options, () => new NopeObservable());
});
return container.instance
}