Is there a better way to observe the "in-flight" status? #1424
Czajnikowski
started this conversation in
Ideas
Replies: 1 comment
-
@Czajnikowski There’s no way to query for an effect’s status directly, but you could use the lifecycle of @State var isNumberFactRequestInFlight = false
var body: some View {
// …
Button("Number fact") {
self.isNumberFactRequestInFlight = true
Task {
await viewStore.send(.numberFactButtonTapped).finish()
self.isNumberFactRequestInFlight = false
}
}
} You lose some testability here, but not much, and arguably surface area that isn’t worth testing at the domain layer. If you have other ideas of how to solve the problem, please do share! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In one of the sample code files, we use
isNumberFactRequestInFlight
boolean to keep an eye on the status of the network request. The problem with that is that it's actually a secondary source of truth that has to be manually maintained, and the ultimate source of such status is in the effect itself (?). I'm wondering if there is a better way to go about such status.I likely missed some episode that fixes this issue, or if that's not the case then maybe we can think about an improvement?
Beta Was this translation helpful? Give feedback.
All reactions