Skip to content

mattbasta/grommet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Grommet

A library for making it easy to make dependencies in JS. Grommet is largely an abstraction of jQuery callbacks and deferred objects.

Examples

Run tasks in order

function task1() {}
function task2() {}
function task3() {}

grom(task1).then(task2).then(task3).go();

Delay a task with a callback

var cb = grom(function() { /* callback */ });

$.get("/path/to/url.html", cb.delay(function(data) {
    /* Process data */
}));

navigator.geolocation.getCurrentPosition(cb.delay(function(location) {
    /* Process the user's location */
}));

var i = new Image();
i.onload = cb.delay(function() {});

cb.go();

Delay tasks with other grommet tasks

var master = grom(function() {
    /* Start video game logic */
});

var secondary = grom(function() {
    /* Initialize video game assets, hide loader */
});

for(var a in assets) {
    var asset = new Asset(a, secondary.delay(function() {
        loaded_assets[a] = asset;
    }));
}
master.after(secondary).go();
secondary.go();

About

JavaScript dependency tracker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published