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

[WIP] Replace OpenHABTracker, use Observable variables for new tracker and Preferences #810

Merged
merged 12 commits into from
Sep 16, 2024

Conversation

digitaldan
Copy link
Contributor

@digitaldan digitaldan commented Sep 11, 2024

Uses "Combine" framework to watch OpenHABTracker state changes. Also allows native rendering for Sitemap navigation from notifications (which led to the refactor) and a small number of other network fixes.

This is my first time using Combine, so it might be a bit rough, but much more flexible then using delegates. The openHABTracker code still needs a good cleanup when we remove AlamoFire.

EDIT:
This is now a larger refactor which replaces the OpenHABTracker with a new class, and make it along with Preferences observable, no more delegates.

@digitaldan digitaldan force-pushed the tracker-combine-changes branch from 743afad to 509dd83 Compare September 11, 2024 21:26
@digitaldan
Copy link
Contributor Author

fyi , i'm probably going to close this. I ended up throwing out the tracker for a much more modern one. I

@timbms
Copy link
Contributor

timbms commented Sep 13, 2024

I could not have helped on Combine. More and more of this Apple framework is replaced by async/await

@digitaldan
Copy link
Contributor Author

For reactive / event based observation of values, like our preference object, or the tracker logic where subscribers want to know when values changes (like our connection state) , but not make actual network calls themselves, I would think Combine is still the correct choice ? Or is there a better option ?

@digitaldan
Copy link
Contributor Author

I guess this looks like a replacement for combine, but its only available in ios 17

https://developer.apple.com/documentation/Observation

@timbms
Copy link
Contributor

timbms commented Sep 13, 2024

@observableobject should be the precursor to @observable and be very close in functionality

Could be done in the last step migrating to SwiftUi

@digitaldan
Copy link
Contributor Author

So i completely rewrote a new tracker class. This has logic for trying connections in parallel, checking the current connection, supports priority ordering of connections (which one to pick in a tie) and will eventually support multiple connection pairs (think N number of connection configurations) . This also uses observable values instead of relying on delegates. It still relies on the NetworkConnection class and so AlamoFire, but that will be fixed in a latter PR (along with async/await conversions)

I also refactored the Preferences class to support observable values. I plan on another PR, to refactor other parts of the code to start using this and get rid of a lot of ugly code.

I'm going to test this quite a bit before moving on, also we need to merge the other PRs first, then i can update this to support those changes (swift ui changes)

@digitaldan
Copy link
Contributor Author

Oh, and this new Tracker is now in the OpenHABCore package, and can be shared with the watch app (another PR)

@digitaldan digitaldan changed the title Migrate Tracker to use Combine Framework [WIP] Replace OpenHABTracker, use Observable variables for new tracker and Preferences Sep 13, 2024
@observableobject
Copy link

observableobject commented Sep 13, 2024 via email

@timbms
Copy link
Contributor

timbms commented Sep 14, 2024

I upgraded Gemfile.lock to overcome the issue on Run Unit Tests

@digitaldan
Copy link
Contributor Author

Thanks!

…allows native rendering for Sitemap navigation from notifications (which led to the refactor)

Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
@digitaldan digitaldan force-pushed the tracker-combine-changes branch from c0fef14 to e7a35b8 Compare September 14, 2024 19:00
@digitaldan
Copy link
Contributor Author

So i'm done with this, i have been testing it as best as i can, cellular, wifi, vpn, cloud, etc.... Both in strong and poor network conditions. So far this seems to work better then what we had, and is much cleaner IMHO. If there are no objections i think we should merge and get some testing on it.

@timbms
Copy link
Contributor

timbms commented Sep 15, 2024

So i'm done with this, i have been testing it as best as i can, cellular, wifi, vpn, cloud, etc.... Both in strong and poor network conditions. So far this seems to work better then what we had, and is much cleaner IMHO. If there are no objections i think we should merge and get some testing on it.

Yes please, let's get this out.

@digitaldan digitaldan force-pushed the tracker-combine-changes branch from 96b9cf9 to cdcd3a7 Compare September 16, 2024 02:47
Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: Dan Cunningham <[email protected]>
@digitaldan digitaldan merged commit 778d68e into openhab:develop Sep 16, 2024
2 checks passed
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.

3 participants