feat(plugin): Network Information and global offline/online events

This commit is contained in:
Max Lynch
2015-09-28 15:03:13 -05:00
parent 0647967fe3
commit 72658bd970
2 changed files with 65 additions and 0 deletions

View File

@@ -50,6 +50,23 @@ export class IonicApp {
this.components = {};
}
/**
* Bind some global events and publish on the 'app' channel
*/
bindEvents(events) {
window.addEventListener('online', (event) => {
events.publish('app:online', event);
}, false);
window.addEventListener('offline', (event) => {
events.publish('app:offline', event);
}, false);
window.addEventListener('orientationchange', (event) => {
events.publish('app:rotated', event);
});
}
/**
* TODO
* @param {Object} appRef TODO
@@ -302,6 +319,8 @@ export function ionicBootstrap(rootComponentType, views, config) {
let translate = new Translate();
let navRegistry = new NavRegistry(views);
app.bindEvents(events);
// add injectables that will be available to all child components
let appBindings = Injector.resolve([
bind(IonicApp).toValue(app),