npm.io
0.2.1 • Published 12 years ago

gumup

Licence
MIT
Version
0.2.1
Deps
0
Vulns
0
Weekly
0

Gumup

Gumup is simple JavaScript library that lets to control the order of modules initialization.

Basic usage

Include Gumup in your page. The library unconditionally occupies a gumup global.

<script src="gumup.js"></script>

Declare your moudles using gumup.unit. Unit implementation function will called in context of created unit instance.

gumup.unit('common.foo', function() {
    this.myFunc = function() {};
});

If you need a custom object, it can be returned from the implementation function. It can be an object, function or primitive.

gumup.unit('utils.bar', function() {
    return "my unit";
});

Use require method of module to specify its dependencies.

var unit = gumup.unit('main', implementation);

unit.require('common.foo');
unit.require('utils.bar');

function implementation(units) {
    units.common.foo.myFunc();
    units.utils.bar;
}

Hook gumup.init() to the page load event.

Grunt task grunt-gumup for resolving unit dependencies.

Keywords