From 21444daefb994555ebaf1ff4206f4e072535f73b Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Wed, 15 May 2024 15:36:59 -0400 Subject: [PATCH] Add jsdoc comments to registerService and patchService --- packages/backend/src/services/Container.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/backend/src/services/Container.js b/packages/backend/src/services/Container.js index 6df9b693..ee85eb9b 100644 --- a/packages/backend/src/services/Container.js +++ b/packages/backend/src/services/Container.js @@ -26,12 +26,27 @@ class Container { this.instances_ = {}; 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) { const my_config = config.services?.[name] || {}; this.instances_[name] = cls.getInstance ? cls.getInstance({ 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) { const original_service = this.instances_[name]; const patch_instance = new patch();