Skip to content

Commit

Permalink
refactor: use function to extend context provider registry
Browse files Browse the repository at this point in the history
  • Loading branch information
azech-hqs committed Sep 1, 2022
1 parent 8f1170b commit 04f136f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@babel/register": "^7.16.0",
"@babel/runtime-corejs3": "7.16.8",
"@exabyte-io/application-flavors.js": "2022.7.24-0",
"@exabyte-io/code.js": "2022.8.31-0",
"@exabyte-io/code.js": "git+https://github.com/Exabyte-io/code.js.git#eb7003eaaf63699d4ef04093dd26050595e98200",
"@exabyte-io/made.js": "2022.6.15-0",
"@exabyte-io/periodic-table.js": "2022.6.8-0",
"lodash": "^4.17.21",
Expand Down
44 changes: 26 additions & 18 deletions src/context/registry.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
import _ from "underscore";
import { ContextProviderRegistryContainer } from "@exabyte-io/code.js/dist/context";
import { createAndPatchRegistry } from "@exabyte-io/code.js/dist/context";

import {
QEPWXContextProvider,
NWChemTotalEnergyContextProvider,
QENEBContextProvider,
QEPWXContextProvider,
VASPContextProvider,
VASPNEBContextProvider,
NWChemTotalEnergyContextProvider,
} from "../context";

const adeContextProviders = {
QEPWXInputDataManager: QEPWXContextProvider.getConstructorConfig({ name: "input" }),
QENEBInputDataManager: QENEBContextProvider.getConstructorConfig({ name: "input" }),
VASPInputDataManager: VASPContextProvider.getConstructorConfig({ name: "input" }),
VASPNEBInputDataManager: VASPNEBContextProvider.getConstructorConfig({ name: "input" }),
NWChemInputDataManager: NWChemTotalEnergyContextProvider.getConstructorConfig({ name: "input" }),
}

const clsInstance = new ContextProviderRegistryContainer();
_.map(adeContextProviders, (instance, name) => clsInstance.addProvider({
instance,
name
}));
export const adeProviders = {
QEPWXInputDataManager: {
providerCls: QEPWXContextProvider,
config: { name: "input" },
},
QENEBInputDataManager: {
providerCls: QENEBContextProvider,
config: { name: "input" },
},
VASPInputDataManager: {
providerCls: VASPContextProvider,
config: { name: "input" },
},
VASPNEBInputDataManager: {
providerCls: VASPNEBContextProvider,
config: { name: "input" },
},
NWChemInputDataManager: {
providerCls: NWChemTotalEnergyContextProvider,
config: { name: "input" },
},
};

export const ContextProviderRegistry = clsInstance;
export const ContextProviderRegistry = createAndPatchRegistry(adeProviders);

0 comments on commit 04f136f

Please sign in to comment.