Connection lifecycle#39
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the peripheral connection lifecycle in the ReliaBLE library by wiring CoreBluetooth connect/disconnect/fail delegate paths into BluetoothActor, exposing per-peripheral connection-state transitions as a multi-subscriber AsyncStream, and updating the demo + docs + tests to exercise and consume the new stream.
Changes:
- Add public connection-state models (
ConnectionState,ConnectionStateChange) and a newReliaBLEManager.connectionStateChangesstream plusdisconnect(from:). - Implement connection registry + broadcasting in
BluetoothActor, including optimistic.connecting/.disconnectingtransitions and delegate-driven.connected/.disconnected/.failed. - Add mock-driven lifecycle tests and update DocC + Demo app to consume and display connection state.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/ReliaBLETests/ReliaBLEManagerTests.swift | Adds connection lifecycle tests and mock-spec support for connect/disconnect/failure flows. |
| Sources/ReliaBLE/ReliaBLEManager.swift | Exposes connectionStateChanges, currentConnectionStates, and a new disconnect(from:) API. |
| Sources/ReliaBLE/Models/PeripheralError.swift | Extends public error surface with connection-related cases and a CBError mapper. |
| Sources/ReliaBLE/Models/ConnectionState.swift | Introduces public connection-state types used by the stream and snapshot. |
| Sources/ReliaBLE/Documentation.docc/GettingStarted.md | Documents connection lifecycle and adds a connection-state stream example. |
| Sources/ReliaBLE/BluetoothActor.swift | Implements connection state registry, stream broadcaster, connect/disconnect, and delegate event handling. |
| docs/reviews/connection-lifecycle-stream-plan-critique-2026-06-30.md | Adds a critique document for the connection-lifecycle plan. |
| docs/plans/connection-lifecycle-stream-2026-06-30.md | Adds the implementation plan referenced by the PR. |
| Demo/ReliaBLE Demo/ReliaBLE Demo/Central/CentralViewModel.swift | Stores transient per-device connection state and updates it on the main actor. |
| Demo/ReliaBLE Demo/ReliaBLE Demo/Central/CentralView.swift | Subscribes to connection-state stream and adds connect/disconnect UI in the detail view. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
10a56c0 to
14c9443
Compare
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.
Plan: docs/plans/connection-lifecycle-stream-2026-06-30.md
Closes #36