docs: document subscribe() callbacks and lock notifications#532
Draft
bluetoothbot wants to merge 1 commit into
Draft
docs: document subscribe() callbacks and lock notifications#532bluetoothbot wants to merge 1 commit into
bluetoothbot wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Add a README "Subscribing to state changes" section documenting the
subscribe()callback API and how lock notifications surface real-time state.Why: Open Question #489 asks how lock event subscription works — the mechanism (
subscribe()→ callback → unsubscribe, plus the connected-notification path for locks) is undocumented anywhere user-facing. New integrators have to readdevice.py/lock.pyto discover it.How: Documents the observable contract derived from the code:
subscribe(callback)registers a zero-arg callback and returns an unsubscribe fn; callbacks fire afterupdate()and on unsolicited notifications while connected;lock()/unlock()enable notifications for the operation window so manual operation during it fires the callback. Includes a runnable lock example.Testing: Docs-only (Markdown). Example mirrors the existing WoLock snippets and the public accessors (
subscribe,update,get_lock_status,unlock) as they exist onmain.Autonomous contribution by Kōan, on behalf of Nick (nick@openhomefoundation.org).
Quality Report
Changes: 1 file changed, 46 insertions(+)
Code scan: 1 issue(s) found
README.md:138— debug print statementTests: passed (1300 passed)
Branch hygiene: clean
Generated by Kōan