nope/lib/dispatcher/getDispatcher.ts

17 lines
613 B
TypeScript
Raw Normal View History

2020-08-30 08:25:53 +00:00
import { getSingleton } from "../helpers/singletonMethod";
import { nopeDispatcher } from "./nopeDispatcher";
import { nopeRpcDispatcherOptions } from "../types/communication.interface";
import { nopeObservable } from "../observables/nopeObservable"
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-09-17 06:05:45 +00:00
export function getRpcDispatcher(options: nopeRpcDispatcherOptions) {
2020-08-30 08:25:53 +00:00
const container = getSingleton('nopeBackendDispatcher.instance', () => {
return new nopeDispatcher(options, () => new nopeObservable());
});
return container.instance
}