-
-
Notifications
You must be signed in to change notification settings - Fork 80
Refactor event subscription #868
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
Conversation
|
Still have a few tests I want to add but we can discuss the overall design first. I also have the nested task thing to take care of. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev #868 +/- ##
==========================================
+ Coverage 80.70% 80.74% +0.04%
==========================================
Files 167 168 +1
Lines 4229 4244 +15
Branches 423 423
==========================================
+ Hits 3413 3427 +14
Misses 642 642
- Partials 174 175 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
68a6139 to
beb718e
Compare
src/Client/NetDaemon.HassClient/Internal/HomeAssistantConnection.cs
Outdated
Show resolved
Hide resolved
src/Client/NetDaemon.HassClient.Tests/Integration/WebsocketIntegrationTests.cs
Outdated
Show resolved
Hide resolved
src/Client/NetDaemon.HassClient.Tests/Integration/WebsocketIntegrationTests.cs
Outdated
Show resolved
Hide resolved
src/HassModel/NetDaemon.HassModel.Tests/Internal/EntityAreaCachTests.cs
Outdated
Show resolved
Hide resolved
9c32ee9 to
f0cd95e
Compare
|
I missed a few spots in the tests and also fixed old tests that had the same problem. I will merge this now. Thanks for the review @FrankBakkerNl |
f0cd95e to
5dc6874
Compare
Breaking change
This PR introduces some breaking changes. The rationale for these changes is to allow more granular subscriptions to events and remove default subscriptions to all events for users of
IHomeAssistantConnection.Most users does not use the
HassClientand should not be affected by this change.IHomeAssistantConnection
ProcessHomeAssistantEventsAsyncmethod no longer defaults to subscribing to all event changes. That logic is moved the new methodSubscribeToHomeAssistantEventsAsyncthat returns theIObservable<HassEvent>instead of make it available as a property on the interface itself.OnHomeAssistantEventis removed and replaced by the methodSubscribeToHomeAssistantEventsAsyncServiceCollectionExtensions
IObservable<HassEvent>is no longer injectable through DI due to internal design change providing it through theSubscribeToHomeAssistantEventsAsyncon theIHomeAsstantConnectioninterface instead.Proposed change
This PR refactors how event subscriptions work. Now it does not automatically subscribe to all events from the HomeAssistantConnection. The runtime and HassModel do add these subscriptions automatically. The function now also supports subscribing to specific avents.
Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: