service-locator

1.0.0 • Public • Published

service-locator - A simple service locator for JavaScript

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.

Service Locator on wikipedia

Installation

 npm install service-locator

Usage

Register your functions, objects, string etc using register(). Once registered with the service locator there is no way to change it.

 
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
 

Credits

Paul Serby

Licence

Licenced under the New BSD License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    120
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    120
  • 0.0.2
    11
  • 0.0.1
    2

Package Sidebar

Install

npm i service-locator

Weekly Downloads

133

Version

1.0.0

License

none

Last publish

Collaborators

  • serby