ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.95k stars 13.51k forks source link

bug: platform resume won't trigger change #18342

Closed loopezz closed 5 years ago

loopezz commented 5 years ago

Bug Report

Ionic version:

[x] 4.4.0

Current behavior: View won't get automatically updated after setting new values inside platform.resume.subscribe function. However, the view will be updated after a minimal touch on the screen of the device.

Expected behavior: Automatically trigger an change update after setting new values inside platform.resume.subscribe function.

Workaround: Using ngZone.run inside platform.resume.subscribe function will solve this issue, but I guess it shouldn't be needed.

Steps to reproduce:

  1. Checkout the related code
  2. Install app on a device or simulator
  3. Run the app
  4. Click the device's "Home" button
  5. Open the app from background

Related code: https://github.com/loopezz/async-update.git

this.platform.resume.subscribe(() => {
  // this.ngZone.run(() => {
    // Text will not be visible updated without running inside ngZone
    this.fakeHttp.updateText();
  // });
});

Other information:

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.4.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms     : ios 5.0.1
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 4 other plugins)

System:

   ios-deploy : 1.9.4
   ios-sim    : 8.0.1
   NodeJS     : v10.15.3 (/usr/local/bin/node)
   npm        : 6.9.0
   OS         : macOS Mojave
   Xcode      : Xcode 10.2.1 Build version 10E1001
paulstelzer commented 5 years ago

Thanks for your issue! It depends on your app. You need to run it with ngZone to call change detection. In your case you have to do it. It has nothing to do with Ionic what you describe

ionitron-bot[bot] commented 5 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.