Skip to content

Commit 4b0528a

Browse files
committed
use event instead of emit
1 parent 4b5c8b0 commit 4b0528a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

docs/tildagon-apps/reference/badge-hardware.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,16 @@ from system.hexpansion.events import \
590590
HexpansionRemovalEvent, HexpansionInsertionEvent
591591
```
592592

593-
Then `emit()` the event as following:
593+
Then attach a function to the event as following:
594594

595595
```python
596-
eventbus.emit(
597-
events.RequestChargeEvent(events.PowerEvent("Charge Cycle change"))
598-
)
596+
class ChargeApp(app.App):
597+
def __init__(self):
598+
eventbus.on(events.RequestChargeEvent, self._handle_charge_event, self)
599+
600+
def _handle_charge_event(self, event: RequestChargeEvent):
601+
# do something
602+
return None
599603
```
600604

601605
## I2C

0 commit comments

Comments
 (0)