Is it possible to create an RxJS observable using the fromEvent method based on the Cordova network connection plugin?
I am attempting this with Ionic 2.
I have noticed that the Cordova network connection plugin offers two events (online/offline). How can I subscribe to these events using RxJS?
Here is an example of what I am trying to achieve:
const offline$ = Observable.fromEvent(CORDOVA_OFFLINE_EVENT);
offline$.subscribe(
function (connectionType) {
console.log("connectionType", JSON.stringify(connectionType));
},
function (err) {
console.log('Error: ' + err);
},
function () {
console.log('Completed');
}
);