rogergl
rogergl

Reputation: 3781

ember 2.0, Cordova and onDeviceReady

The code in app.js looks like this:

var App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver: Resolver
});

export default App;

How do I use deferReadiness and advanceReadiness here ? I need this to call advanceReadiness if the cordova deviceReady event is fired.

Upvotes: 3

Views: 318

Answers (1)

Marcio Junior
Marcio Junior

Reputation: 19128

You can get the application from within an initializer:

Just use ember generate initializer cordova to generate a new initializer.

This will generate a file named app/initializers/cordova.js. And then you can change it to listen the deviceready event like so:

export function initialize(container, application) {
  application.deferReadiness();
  document.addEventListener("deviceready", function() {
    application.advanceReadiness();
  }, false);
}

export default {
  name: 'cordova',
  initialize: initialize
};

Upvotes: 2

Related Questions