Skip to content

Make ViewStore.yield(while:) main actor. #1517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2022
Merged

Make ViewStore.yield(while:) main actor. #1517

merged 1 commit into from
Oct 17, 2022

Conversation

mbrandonw
Copy link
Member

Considering that viewStore.send(_:while:) is @MainActor, it seems this one should be too.

@jshier
Copy link
Contributor

jshier commented Oct 17, 2022

I'm not sure this follows logically. While send(_:while:) is on main since it's primary use is to handle loading, yield(while:) seems like a sort of primitive that could be used for any conditional wait, including those off main. Unless, is this a move towards bringing reducers entirely onto main?

@stephencelis
Copy link
Member

@jshier Because the condition is derived from state that lives on the main actor, we think it's important that it runs here as well.

We've also already had to push this direction for any reducers that use async effects, and we also deprecated Store.unchecked awhile ago.

We'll be able to revisit more aspects of the task/threading model in the future when we can abandon the rest of our pre-concurrency thread model, and should eventually get back to a space where we can better support both Swift concurrency and non-main reducers/stores, but weren't able to maintain both during these current, migratory moments.

Copy link
Member

@stephencelis stephencelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I think this was just an oversight and we probably should have added it when it first shipped.

@jshier
Copy link
Contributor

jshier commented Oct 17, 2022

We'll be able to revisit more aspects of the task/threading model in the future when we can abandon the rest of our pre-concurrency thread model, and should eventually get back to a space where we can better support both Swift concurrency and non-main reducers/stores, but weren't able to maintain both during these current, migratory moments.

Ah, makes sense. Non-main reducers will likely become more important as things continue to scale.

@mbrandonw mbrandonw merged commit ed34c76 into main Oct 17, 2022
@mbrandonw mbrandonw deleted the main-actor-yield branch October 17, 2022 18:59
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.

3 participants