Skip to content

Conversation

@bfollington
Copy link

This significantly improves UI responsiveness in the main Subconscious app.

/// `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
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Author

Choose a reason for hiding this comment

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

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.

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.

2 participants