service-locator
Version:
service-locator helps keep your system decoupled by providing a central location where your application information can be found by other parts of you application.
37 lines (22 loc) • 918 B
Markdown
service-locator helps keep your system decoupled by providing a central registry
where your application information can be found by other parts of you
application.
[](http://en.wikipedia.org/wiki/Service_locator_pattern)
npm install service-locator
Register your functions, objects, string etc using register().
Once registered with the service locator there is no way to change it.
```js
var serviceLocator = require('service-locator')()
, foo = 'bar'
serviceLocator.register('foobar', foo)
console.log(serviceLocator.foobar) // bar
serviceLocator.register('logger', console)
serviceLocator.logger.log('Hello world') // Hello world
```
[](https://github.com/serby/)
Licenced under the [New BSD License](http://opensource.org/licenses/bsd-license.php)