Skip to content

Conversation

@mbrandonw
Copy link
Member

This should fix #1130, but it's also something we will be doing in our upcoming TCA concurrency updates, so might as well get a little bit of this in now.

Effectively this means that one no longer needs to do Effect.task { @MainActor ... } if using this API inside a reducer. It will be done automatically for you, and you don't even need .receive(on: ...).

However, we still do not recommend using Effect.task directly in a reducer unless you are willing to deal with the annoyances that come with it when testing. In particular, you either need to add some super short expectations in order to allow the task to do its work, or you need to make your test async and sprinkle in some await Task.yield()s.

Our upcoming concurrency tools for TCA will make this much nicer.

@mbrandonw mbrandonw requested a review from stephencelis June 3, 2022 21:42
@mbrandonw mbrandonw merged commit 52a1bff into main Jun 3, 2022
@mbrandonw mbrandonw deleted the main-actor-task branch June 3, 2022 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sometime actions doesn't received from async throws Effect.task

3 participants