You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just started with TCA, so forgive me if there is a easy solution i failed to see.
I have a Service, that downloads the latest datapoints and returns it as an AsyncSequence. I want to display 4 datapoints in my feature simultaneously, so when i refresh all, i .merge Effects like this:
[...]
Reduce { state, action in
switch action {
case .refresh:
return .merge(
updateData(1),
updateData(2),
updateData(3),
)
}
}
[...]
private func updateData(_ src: Int) -> Effect<Action> {
return .run { send in
let asyncStream = service.fetch(src)
for await result in stream {
await send(.update(src: src, with: result)))
}
}
}
This works fine and the fetches are simultaneous, but testing doesn't work when i try it like this:
When checking the Effects the sequence is always changing, so it fails at random whenever one mocked execution is resolved a nanosecond faster.
When checking the State the effects of other Effects are sometimes taken into account, so that depending on the runing device, i sometimes get the last state in the first .receive(.update(..)) and all following .receive(.update(..)) calls don't have any state changes
Currently this test succeeds on my system, but it doesn't feel like it should and like it could collapse at any moment:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I just started with TCA, so forgive me if there is a easy solution i failed to see.
I have a Service, that downloads the latest datapoints and returns it as an
AsyncSequence
. I want to display 4 datapoints in my feature simultaneously, so when i refresh all, i.merge
Effects like this:This works fine and the fetches are simultaneous, but testing doesn't work when i try it like this:
Effect
s the sequence is always changing, so it fails at random whenever one mocked execution is resolved a nanosecond faster..receive(.update(..))
and all following.receive(.update(..))
calls don't have any state changesCurrently this test succeeds on my system, but it doesn't feel like it should and like it could collapse at any moment:
Is there a good method to testing parallel effects / actions in TCA?
Beta Was this translation helpful? Give feedback.
All reactions