knifecycle icon indicating copy to clipboard operation
knifecycle copied to clipboard

Consider changing some internal services to singletons

Open nfroidure opened this issue 2 years ago • 1 comments

Some services, like $fatalError should probably be singletons since they concern the processes (its only use is atm here: https://github.com/nfroidure/common-services/blob/main/src/process.ts#L84-L88

Some other ain't that simple to determine INJECTOR and SILO_CONTEXT are not singletons and it looks difficult to change their nature: https://github.com/nfroidure/knifecycle/blob/86a34ca367a13cbfa62def2a98bca0a5d0fdd180/src/index.ts#L397-L398

Maybe that the autoloader itself should not be a singleton and be tied to its silo context? That said since initializers are the same for all silos, the autoloader would be a singleton that finally load the same things for each silos? Weird... Or not?

Have to think about it more, let's not include it into the v16.

nfroidure avatar Aug 16 '23 08:08 nfroidure

$fatalError is now a singleton and a separate file in the codebase https://github.com/nfroidure/knifecycle/blob/main/src/fatalError.ts#L56

nfroidure avatar Sep 04 '23 09:09 nfroidure