mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(plugin): Network Information and global offline/online events
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user