Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. constructor(
  2. private platform: Platform,
  3. private splashScreen: SplashScreen,
  4. private statusBar: StatusBar,
  5. private router:Router,
  6. private menu:MenuController,
  7. private logeo:LoginService,
  8. private nvctr:NavController,
  9. private activated_rout:ActivatedRoute,
  10. private network:Network,
  11. private loading_c:LoadingController
  12. ) {
  13. this.network_check()
  14. this.initializeApp();
  15. }
  16.  
  17.  
  18. network_check() {
  19.  
  20.  
  21. // watch network for a disconnection
  22. let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
  23. this.loading_present('mostrar')
  24. });
  25.  
  26. // stop disconnect watch
  27. disconnectSubscription.unsubscribe();
  28.  
  29.  
  30. // watch network for a connection
  31. let connectSubscription = this.network.onConnect().subscribe(() => {
  32. this.loading_present('esconder')
  33. // We just got a connection but we need to wait briefly
  34. // before we determine the connection type. Might need to wait.
  35. // prior to doing any api requests as well.
  36.  
  37. });
  38.  
  39. // stop connect watch
  40. connectSubscription.unsubscribe();
  41.  
  42. }
  43.  
  44. async loading_present(condicion:String) {
  45. const loading = await this.loading_c.create({
  46. message: 'Esperando conectividad'
  47.  
  48. })
  49. if(condicion == 'mostrar'){
  50.  
  51. loading.present()
  52.  
  53. }
  54.  
  55. else{
  56.  
  57. loading.dismiss()
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement