mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Add jsdoc comments to registerService and patchService
This commit is contained in:
parent
2e0d7361cb
commit
21444daefb
@ -26,12 +26,27 @@ class Container {
|
|||||||
this.instances_ = {};
|
this.instances_ = {};
|
||||||
this.ready = new TeePromise();
|
this.ready = new TeePromise();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* registerService registers a service with the servuces container.
|
||||||
|
*
|
||||||
|
* @param {String} name - the name of the service
|
||||||
|
* @param {BaseService.constructor} cls - an implementation of BaseService
|
||||||
|
* @param {Array} args - arguments to pass to the service constructor
|
||||||
|
*/
|
||||||
registerService (name, cls, args) {
|
registerService (name, cls, args) {
|
||||||
const my_config = config.services?.[name] || {};
|
const my_config = config.services?.[name] || {};
|
||||||
this.instances_[name] = cls.getInstance
|
this.instances_[name] = cls.getInstance
|
||||||
? cls.getInstance({ services: this, config, my_config, name, args })
|
? cls.getInstance({ services: this, config, my_config, name, args })
|
||||||
: new cls({ services: this, config, my_config, name, args }) ;
|
: new cls({ services: this, config, my_config, name, args }) ;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* patchService allows overriding methods on a service that is already
|
||||||
|
* constructed and initialized.
|
||||||
|
*
|
||||||
|
* @param {String} name - the name of the service to patch
|
||||||
|
* @param {ServicePatch.constructor} patch - the patch
|
||||||
|
* @param {Array} args - arguments to pass to the patch
|
||||||
|
*/
|
||||||
patchService (name, patch, args) {
|
patchService (name, patch, args) {
|
||||||
const original_service = this.instances_[name];
|
const original_service = this.instances_[name];
|
||||||
const patch_instance = new patch();
|
const patch_instance = new patch();
|
||||||
|
Loading…
Reference in New Issue
Block a user