|
| 1 | + |
| 2 | +# Battery API Events |
| 3 | + |
| 4 | +<primary-label ref="events"/> |
| 5 | +<show-structure for="chapter" depth="2"/> |
| 6 | + |
| 7 | +The battery will automatically emit the following events (and intentions) |
| 8 | +during its lifecycle. |
| 9 | + |
| 10 | +<note> |
| 11 | +More information about events can be found in the <a href="events.md">events |
| 12 | +documentation</a>. |
| 13 | +</note> |
| 14 | + |
| 15 | +## Charging State Changed Event |
| 16 | +<secondary-label ref="event"/> |
| 17 | + |
| 18 | +An `Boson\WebView\Api\Battery\Event\BatteryChargingStateChanged` event fired |
| 19 | +after charging state has been changed. |
| 20 | + |
| 21 | +```php |
| 22 | +class BatteryChargingStateChanged<WebView> |
| 23 | +{ |
| 24 | + public readonly bool $isCharging; |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +## Charging Level Changed Event |
| 29 | +<secondary-label ref="event"/> |
| 30 | + |
| 31 | +An `Boson\WebView\Api\Battery\Event\BatteryLevelChanged` event fired |
| 32 | +after charging level has been changed. |
| 33 | + |
| 34 | +```php |
| 35 | +class BatteryLevelChanged<WebView> |
| 36 | +{ |
| 37 | + public readonly float<0.0, 1.0> $level; |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## Charging Time Changed Event |
| 42 | +<secondary-label ref="event"/> |
| 43 | + |
| 44 | +An `Boson\WebView\Api\Battery\Event\BatteryChargingTimeChanged` event fired |
| 45 | +after charging time has been changed. |
| 46 | + |
| 47 | +```php |
| 48 | +class BatteryChargingTimeChanged<WebView> |
| 49 | +{ |
| 50 | + public readonly int<0, max> $chargingTime; |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +## Discharging Time Changed Event |
| 55 | +<secondary-label ref="event"/> |
| 56 | + |
| 57 | +An `Boson\WebView\Api\Battery\Event\BatteryDischargingTimeChanged` event fired |
| 58 | +after discharging time has been changed. |
| 59 | + |
| 60 | +```php |
| 61 | +class BatteryDischargingTimeChanged<WebView> |
| 62 | +{ |
| 63 | + public readonly ?int<0, max> $dischargingTime; |
| 64 | +} |
| 65 | +``` |
0 commit comments