Skip to content

Instantly share code, notes, and snippets.

@ozexpert
Created February 28, 2014 16:14
Show Gist options
  • Save ozexpert/9273851 to your computer and use it in GitHub Desktop.
Save ozexpert/9273851 to your computer and use it in GitHub Desktop.
Super useful cordova ready factory (same as device ready in Cordova)
YourModule.factory('CordovaReady', function() {
return function (fn) {
var queue = [];
var impl = function () {
queue.push(Array.prototype.slice.call(arguments));
};
document.addEventListener('deviceready', function () {
queue.forEach(function (args) {
fn.apply(this, args);
});
impl = fn;
}, false);
return function () {
return impl.apply(this, arguments);
};
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment