cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daserge <...@git.apache.org>
Subject [GitHub] cordova-plugin-battery-status pull request #42: CB-8929 Use PowerManager to ...
Date Tue, 08 Nov 2016 08:30:39 GMT
Github user daserge commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-battery-status/pull/42#discussion_r86942697
  
    --- Diff: src/windows/BatteryProxy.js ---
    @@ -19,7 +19,38 @@
      *
      */
     
    -/* global WinJS, BatteryStatus */
    +/* global Windows, WinJS, BatteryStatus */
    +
    +var PowerManager = Windows && Windows.System &&
    +    Windows.System.Power && Windows.System.Power.PowerManager;
    +
    +if (PowerManager) {
    +    var BatteryWin10 = {
    +        start: function (win, fail) {
    +
    +            function reportStatus() {
    +                win({
    +                    level: PowerManager.remainingChargePercent,
    +                    isPlugged: PowerManager.powerSupplyStatus !== Windows.System.Power.PowerSupplyStatus.notPresent
    +                }, { keepCallback: true });
    +            }
    +
    +            PowerManager.onremainingchargepercentchanged = reportStatus;
    --- End diff --
    
    Would not it be better to use add/remove event listener here instead to avoid overriding
a listener which might be set in an app code?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message