0.6.0 • Published 11 years ago

pang v0.6.0

Weekly downloads
2
License
mit
Repository
github
Last release
11 years ago

pang

A simple dependency injection library for node

npm install pang

example

The following example illustates setting up a pang domain/kernel.

var pang = require('pang')

var domain = pang.domain()

domain.factory('http', require('http'))

domain.factory('configuration', {

	server: {

		port: 8080
	}
})

domain.factory('repository', function(configuration) {

	return new Repository(configuration)
})

domain.factory('server', function(configuration, http, repository) {
	
	return new Server(configuration, http, repository)
})

domain.start()

Boots all instances in this domain and caches within the domain.

domain.start()

domain.singleton()

Returns a singleton instance from the domain. Will automatically start() the domain if not already started.

var instance = domain.singleton('repository')

domain.transient()

Returns a transient (new) instance from the domain.

var instance = domain.transient('repository')
0.6.0

11 years ago

0.5.9

11 years ago

0.5.8

11 years ago

0.5.7

11 years ago

0.5.6

11 years ago

0.5.5

11 years ago

0.5.4

11 years ago

0.5.3

11 years ago

0.5.2

11 years ago

0.5.1

11 years ago

0.5.0

11 years ago