Refreshable async action causes parent effect to cancel #1866
Unanswered
jansvancer
asked this question in
Q&A
Replies: 0 comments
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 have a situation where I have parent and child features, where child is displayed via NavigationLink and contains a
List
with pull to refresh (refreshable
) action. This refreshable block sends an action which is catched in parent reducer and starts some async operation. But when child feature is dismissed before asynchronous operation is done, it causes this parent operation to cancel.Here is an example situation:
And Child:
Child view calls that pull to refresh action:
So when child sends
.fetchData
parent starts some asynchronous operation, but when you navigate back from child, while the asynchronous operation is running, it causes that this operation is canceled.I think I understand why this is happening.
public func send(_ action: ViewAction, while predicate: @escaping (ViewState) -> Bool) async {
handles the cancelation which is cause by viewStore publisher to be cancelled, if I understand this correctly. And I think this is right behavior for most of the cases.
But how can I break the relationship between that child action which can be cancelled and parent action which performs that async operation? Or should I model this situation completely different? This is just an example. We have quite more complex logic behind it in real situation. And we want that fetching of data to be done in parent feature and just share some result to child feature.
Thank You
Beta Was this translation helpful? Give feedback.
All reactions