Skip to content
Discussion options

You must be logged in to vote

Hey @wtruppel! Forget about the .task modifier for a second:

viewstore.send(.action)

This is a sync function. It returns when the reducer finishes reducing .action. Note however that this doesn't include side-effects like .run, .task, and .fireAndForget that you may have produced, because these ones are not evaluated synchronously. This is similar to what happens with

print("1")
DispatchQueue.global.async {  }
print("2")

This prints "2" immediately, regardless of the duration of what happens in the dispatched block.

viewstore.send(.action).finish()

This is now an async function that will return when all the effects (including side effects) produced by the reducers are finished. It means …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@mbrandonw
Comment options

@ghost
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants