Hello,
I am currently using ionic native network plugin to monitor for connection connect and disconnect, by using the following code
constructor(private network: Network, public platform: Platform) {
this.initializeOrders();
this.getStatus();
let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
console.log('network was disconnected');
this.handler.stop();
});
let connectSubscription = this.network.onConnect().subscribe(() => {
console.log('network connected!');
for (let entry of this.newOrders.find()) {
if(entry.updatedAt) {
this.updateOrder(entry._id,entry.status).then(() => {
this.initGroundedCollectionOrders();
}).catch(function(error) {
console.log('Error -> ' + error.reason);
});
} else if(entry.offline) {
console.log('I detected an object with the offline flag');
}
}
});
}
The challenge I am facing is this; if I run this code in the iOS emulator (with -lc parameters), I test it by bringing the wifi on the laptop offline. After I do that, the ‘network was disconnected’ output is not shown in the console.
When I bring the laptop wifi online again, than the ‘network was disconnected’ output is shown.
After that the app is not responding to any code changes that I make.
It is as if the app is not responding rapidly to these changes at all. How can I somehow test network disconnect/connect and still make the app respond to these connection changes rapidly?