Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to create singleton services #3

Closed
nfroidure opened this issue Oct 30, 2016 · 0 comments
Closed

Allow to create singleton services #3

nfroidure opened this issue Oct 30, 2016 · 0 comments
Assignees
Milestone

Comments

@nfroidure
Copy link
Owner

nfroidure commented Oct 30, 2016

A singleton service instance is available across multiple running silos. It is maintained in a WeakMap in order to avoid spawning multiple instances of a service while ensuring unused services can still be garbage collected.

import { depends, service } from './knifecycle';
import LoggerService from 'logger';

service('logger', depends('stdout', LoggerService), { singleton: true });

Consider checking singleton dependencies are also singletons, not sure it is that important, but with no use case for singleton depending on non-singleton, it may help prevent programming errors.

@nfroidure nfroidure added this to the 2.0.0 milestone Oct 30, 2016
@nfroidure nfroidure self-assigned this Oct 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant