Wrap store.send in Task {}#46
Open
bfollington wants to merge 4 commits intosubconsciousnetwork:mainfrom
Open
Conversation
gordonbrander
requested changes
Mar 1, 2024
| /// `send(_:)` is run *synchronously*. It is up to you to guarantee it is | ||
| /// run on main thread when SwiftUI is being used. | ||
| public func send(_ action: Model.Action) { | ||
| DispatchQueue.main.async { @MainActor in |
Collaborator
There was a problem hiding this comment.
Is there a reason we use this instead of the Task interface?
DispatchQueue is part of the old Grand Central Dispatch async API and does not coordinate with Swift's concurrency green thread implementation. Best avoided.
Author
There was a problem hiding this comment.
I'm having trouble getting the tests to consistently pass using Task { @MainActor in }, but on further experimentation this seems to be an issue regardless of approach.
Each test passes individually but running them together has them all competing to schedule tasks. Let's chat about the best approach on a call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This significantly improves UI responsiveness in the main Subconscious app.