polling feature and direct communication between reducers #2512
Unanswered
mortifactor
asked this question in
Q&A
Replies: 1 comment
-
Hi @mortifactor, it's really hard to say without more information. You say that polling should happen after receiving a 200 from an API request, and so technically all of that could happen directly in one single effect: case .payButtonTapped:
…
return .run { send in
let response = try await self.apiClient.request(…)
await send(.response(response))
for await _ in self.clock.interval(for: .seconds(1)) {
try await self.apiClient.poll()
…
}
} This effect makes the API request, and if it succeeds, right after it starts a timer with a clock so that it can invoke a But also, if you are completely new to iOS development and SwiftUI, I think you may be taking too big of a leap with TCA. I would highly recommend becoming more familiar with the fundamentals of Apple's platforms before jumping into an opinionated library like TCA. |
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.
-
Hello.
I would like to ask for help. I am quite a novice in IOS development and in TCA either.
I want to implement a case when a client in my app taps a "pay" button, receives 200 response from api and an app starts polling periodically my back-end server for "finished" order status. All this process happens in one modal sheet. In addition to this: if user closes this sheet there might be a small card on main screen with some polling animation.
I ended up with an "OrderPrepareFeature" reducer with ".payButtonTapped" action in the end and a corresponding view. But I am stuck with the polling.
I think it should be separate PollingFeature with polling logic. I suppose I can implement this in my root feature so my modal sheet or main screen could have an access to this polling state.
But how, for example, can I send the ".startPolling" action to the "PollingFeature" from my "OrderPrepareFeature" directly?
Or is my whole idea wrong and there might be a better solution?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions