0.2.1 • Published 10 years ago

gumup v0.2.1

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

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.

Related

Grunt task grunt-gumup for resolving unit dependencies.