Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support constructing Peripherals using builder lambda #108

Merged
merged 16 commits into from
Jun 9, 2021
Merged

Conversation

twyatt
Copy link
Member

@twyatt twyatt commented Jun 6, 2021

Usage details can be found in the README Peripherals section.

Worth mentioning (with more detail beyond the README) is the onServicesDiscovered option (in the builder lambda):
It allows for actions to be performed "after service discovery".

Without this feature, performing an action upon connection required wrapping Kable's Peripheral so that operations could be performed after the connect (additionally, ensuring those operations were idempotent and thread-safe was difficult and error prone).

Kable already incorporates the necessary locks/safe-guards so this makes it possible for consumers to leverage that functionality.

The DiscoveredServicesPeripheral was created to provide a reduced functionality Peripheral which is available in the onServiceDiscovered lambda. It excludes the ability connect or disconnect, whereas connect from the lambda would create a deadlock. So, this limited functionality Peripheral prevents a footgun situation.

@twyatt twyatt added this to the 0.5.2 milestone Jun 8, 2021
@twyatt twyatt marked this pull request as ready for review June 8, 2021 05:43
@twyatt twyatt modified the milestones: 0.5.2, 0.6.0, 0.7.0 Jun 8, 2021
Copy link
Contributor

@davidtaylor-juul davidtaylor-juul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 very nice

Copy link
Contributor

@sdonn3 sdonn3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it

- `ReplaceWith` was not working, so dropped
- Fixed deprecated functions overlapping with builder function signature
@twyatt twyatt enabled auto-merge (squash) June 9, 2021 08:13
@twyatt twyatt merged commit f171302 into main Jun 9, 2021
@twyatt twyatt deleted the twyatt/builder branch June 9, 2021 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants