Files
meteor/packages/launch-screen/default-behavior.js
Slava Kim 9e7c14ac81 Globally replace Template.rendered callbacks to Template.onRendered
In:

- examples
- some blaze tests
- packages

Change:

- rendered -> onRendered()
- created -> onCreated()
- destroyed -> onDestroyed()
2015-01-16 16:36:23 -08:00

35 lines
1.2 KiB
JavaScript

// Hold launch screen on app load. This reflects the fact that Meteor
// mobile apps that use this package always start with a launch screen
// visible. (see XXX comment at the top of package.js for more
// details)
var handle = LaunchScreen.hold();
var Template = Package.templating && Package.templating.Template;
Meteor.startup(function () {
if (! Template) {
handle.release();
} else if (Package['iron:router']) {
// XXX Instead of doing this here, this code should be in
// iron:router directly. Note that since we're in a
// `Meteor.startup` block it's ok that we don't have a
// weak dependency on iron:router in package.js.
Package['iron:router'].Router.onAfterAction(function () {
handle.release();
});
} else {
Template.body.onRendered(function () {
handle.release();
});
// In case `Template.body` never gets rendered (due to some bug),
// hide the launch screen after 6 seconds. This matches the
// observed timeout that Cordova apps on Android (but not iOS)
// have on hiding the launch screen (even if you don't call
// `navigator.splashscreen.hide()`)
setTimeout(function () {
handle.release();
}, 6000);
}
});