Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-6065 alignment with W3C Battery API
  3. CB-7590

Cordova W3C Battery Alignment - levelchange event

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      JIRA parent issue: https://issues.apache.org/jira/browse/CB-6065
      Cordova documentation: https://github.com/apache/cordova-plugin-battery-status/blob/master/doc/index.md
      w3c spec: http://www.w3.org/TR/battery-status

      Gap analysis document can be found here: https://docs.google.com/document/d/1mAcjwf39IcIqpIuS-7SzlDxTgk4OebCHae6yfOwnStE/edit?usp=sharing

      levelchange event. When the battery level is updated, the user agent mustqueue a task which sets the level attribute's value and fires a simple eventnamed levelchange at the BatteryManager object.
      event handler: onlevelchange
      Example:
      // We get the initial value when the promise resolves ...
      navigator.getBattery().then(function(battery) {
      console.log(battery.level);
      // ... and any subsequent updates.
      battery.onlevelchange = function()

      { console.log(this.level); };
      });
      Example 2 (Alternative):
      navigator.getBattery().then(function(battery) {
      console.log(battery.level);
      battery.addEventListener('levelchange', function() { console.log(this.level); }

      );
      });

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ldeluca Lisa Seacat DeLuca
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: