Created
February 28, 2014 16:14
-
-
Save ozexpert/9273851 to your computer and use it in GitHub Desktop.
Super useful cordova ready factory (same as device ready in Cordova)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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