nope/lib/loader/getPackageLoader.ts

33 lines
946 B
TypeScript
Raw Normal View History

2020-11-07 00:45:20 +00:00
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @create date 2020-11-06 14:20:32
* @modify date 2020-12-02 08:57:05
2020-11-07 00:45:20 +00:00
* @desc [description]
*/
import { getSingleton } from "../helpers/singletonMethod";
2020-11-15 19:11:25 +00:00
import { INopeDispatcherOptions } from "../types/nope/nopeCommunication.interface";
import { generateNopeBasicPackage } from "./generateNopeBasicPackage";
2020-11-07 00:45:20 +00:00
import { NopePackageLoader } from "./nopePackageLoader";
/**
* Function to extract a Singleton Dispatcher
* @param options The provided options for the Dispatcher
*/
2020-11-15 19:11:25 +00:00
export function getPackageLoader(options: INopeDispatcherOptions) {
const container = getSingleton("nopeBackendPackageLoader.instance", () => {
2020-11-07 00:45:20 +00:00
// Create a loader
2020-11-15 19:11:25 +00:00
const loader = new NopePackageLoader();
2020-11-07 00:45:20 +00:00
// load the default Package:
loader.addPackage(generateNopeBasicPackage(options)).catch((e) => {
2020-11-07 00:45:20 +00:00
throw e;
});
return loader;
2020-11-07 00:45:20 +00:00
});
return container.instance;
}