Post AWduE6abBQn8PiCR7Y by noim@noc.social
(DIR) More posts by noim@noc.social
(DIR) Post #AWcPpW9VoO8afpvhfU by noim@noc.social
2023-06-12T14:58:25Z
0 likes, 0 repeats
What data fetching technics do you use in your #SwiftUI App? I know of Combine and Async Await. But how exactly do you manage your app data with it? In my last (still unfinished) side project I used Combine and I still don’t know if this was the correct choice. #Swift
(DIR) Post #AWcQfkef8Z1Ai7PIlk by Alexbbrown@hachyderm.io
2023-06-12T15:07:52Z
0 likes, 0 repeats
@noim the challenges of fetching data and managing data seem distinct to me.You can likely transition your combine code with only moderate pain to newer AsyncStream, and replace "sink" with await or for await.Can you share more details?
(DIR) Post #AWchhIz0goyQgiFdOC by noim@noc.social
2023-06-12T18:18:39Z
0 likes, 0 repeats
@Alexbbrown My use case for combine was the following: The connection is only reachable in certain networks. This is why the first step of the combine pipeline was the reachability. Then I needed to do a single http request to get the initial value. After this, I connect to a HTTP Event Stream to publish real time update through the combine pipeline. All of this works, kind of. The app sometimes feels a bit funky if multiple things happen at the same time. (1)
(DIR) Post #AWchz735ncDUt4eU1g by noim@noc.social
2023-06-12T18:21:52Z
0 likes, 0 repeats
@Alexbbrown I also don't know if this is really the purpose of combine. It feels like I abuse the framework with this. The application is "device" based. My goal is it to build a control app for valetudo (a smart vacuum os). This is why I create all publishers on the device data class and pass it to all views which need data access. The published value to the pipeline is always a "Result” type which can be idle, loading, error and success. (2)
(DIR) Post #AWciJzORSSANE0anxI by noim@noc.social
2023-06-12T18:25:39Z
0 likes, 0 repeats
@Alexbbrown But my new project is more classical and doesn't need things like real time updates or connects to only certain devices in a network. So I thought, maybe combine is not good for things like this and I should use async await? But it feels like combine is better integrated into swiftui, or am I wrong? For my valetudo app I wrote a ResultRendere helper component which automatically handles the combine publisher state. This was neat, I guess. (3)
(DIR) Post #AWcsUA8PNLe4yaaBsW by Alexbbrown@hachyderm.io
2023-06-12T20:19:20Z
0 likes, 0 repeats
@noim combine is great for what you describe, but async await is awesome at this stuff: easier to write, read and reason about, and you done need the result type at all; "throws" is all you need for error handling.
(DIR) Post #AWcsmy34XGC4zh3ORU by Alexbbrown@hachyderm.io
2023-06-12T20:22:54Z
0 likes, 0 repeats
@noim if you watch the new wwdc videos from 2023 you will see that in ios17 combine is no longer a load bearing component of swiftUI.That won't prevent you from using combine code you have already written however, so if your code already work you can leave or as is, or gradually migrate to the new systems.
(DIR) Post #AWduE6abBQn8PiCR7Y by noim@noc.social
2023-06-13T08:13:46Z
0 likes, 0 repeats
@Alexbbrown Do you have a specific Video in mind? I have poor Network on the campsite and it would be helpful if I could download the specific video offline.
(DIR) Post #AWeNa9RO9xlCIakwng by Alexbbrown@hachyderm.io
2023-06-13T13:42:40Z
0 likes, 0 repeats
@noimHere's three videos to watch. If you have the developer app you can also read the transcripts which might work with low bandwidthdiscover observation in swiftUIhttps://developer.apple.com/wwdc23/10149Meet async / await https://developer.apple.com/wwdc21/10132Use async/await with url session https://developer.apple.com/wwdc21/10095