0.1.3 • Published 10 years ago

lujs v0.1.3

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

lu.js

Lightweight dependency injection lib written in JavaScript.

Usage

var container = lu()

    // services are singletons
    .service('myService', function() {
        return {
            getFoo: function() {
                return 'foo';
            }
        }
    })

    // this is how dependencies get passed in
    .service('myOtherService', ['myService'], function(myService) {
        return myService.getFoo() + ' bar';
    })

    // you can also define values as dependencies
    .value('myVal', ' is a random value')

    // factories get always called when they
    // get injected.
    .factory('myFactory', ['myVal'], function(myVal) {
        return Math.random() + myVal;
    });

// get a registered dependency
var myService = container.get('myService');

// run some anonymous function and pass
// dependencies in
container(['myFactory', 'myVal'], function(myFactory, myVal) {
   console.log(myVal);
});

Installation

Node.JS

npm install lujs

Browser

bower install lu

License

Copyright (c) 2014 Simon Kusterer Licensed under the MIT license.

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago