Skip to content

Commit

Permalink
add unsubscribe to interactive example
Browse files Browse the repository at this point in the history
  • Loading branch information
khusmann committed Dec 24, 2024
1 parent 60c80d0 commit 8e7d15c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/benlink/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,15 @@ def handle_event(event):
await radio.connect()
radio.register_event_handler(lambda x: print(f"Received event: {x}"))
unsubscribe = radio.register_event_handler(lambda x: print(f"Received event: {x}\n"))
# Change the channel on the radio a few times to generate some events
unsubscribe() # Unsubscribe the event handler
# Change the channel on the radio a few times to generate some events and
# observe that the event handler is no longer called
await radio.disconnect() # When you're done with your session disconnect nicely
```
Expand Down

0 comments on commit 8e7d15c

Please sign in to comment.