This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
vogue/System.js

34 lines
720 B
JavaScript
Raw Normal View History

2021-05-02 17:42:04 -04:00
import Instance from './Instance.js';
import Serializable from './Serializable.js';
2021-05-06 09:33:28 -04:00
import _ from 'lodash';
const {get, set} = _;
2021-05-02 17:42:04 -04:00
export default class System extends Serializable {
instances = [];
modules = null;
constructor(modules, location = '.running') {
super();
this.modules = modules;
try {
mkdirSync(location);
} catch {}
2021-05-06 23:05:36 -04:00
this.newInstance('xyz.places.main');
2021-05-06 09:33:28 -04:00
}
getModule(name) {
return get(this.modules, name);
2021-05-02 17:42:04 -04:00
}
createInstance(name, args = {}) {
2021-05-06 09:33:28 -04:00
return new Instance(this.getModule(name), null, args, this);
2021-05-02 17:42:04 -04:00
}
newInstance(name, args = {}) {
const instance = this.createInstance(name, args);
2021-05-06 23:05:36 -04:00
const link = instance.link;
2021-05-02 17:42:04 -04:00
instance.invokeInternal('restore');
return link;
}
}