Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor(
- private platform: Platform,
- private splashScreen: SplashScreen,
- private statusBar: StatusBar,
- private router:Router,
- private menu:MenuController,
- private logeo:LoginService,
- private nvctr:NavController,
- private activated_rout:ActivatedRoute,
- private network:Network,
- private loading_c:LoadingController
- ) {
- this.network_check()
- this.initializeApp();
- }
- network_check() {
- // watch network for a disconnection
- let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
- this.loading_present('mostrar')
- });
- // stop disconnect watch
- disconnectSubscription.unsubscribe();
- // watch network for a connection
- let connectSubscription = this.network.onConnect().subscribe(() => {
- this.loading_present('esconder')
- // We just got a connection but we need to wait briefly
- // before we determine the connection type. Might need to wait.
- // prior to doing any api requests as well.
- });
- // stop connect watch
- connectSubscription.unsubscribe();
- }
- async loading_present(condicion:String) {
- const loading = await this.loading_c.create({
- message: 'Esperando conectividad'
- })
- if(condicion == 'mostrar'){
- loading.present()
- }
- else{
- loading.dismiss()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement