Skip to content

Conversation

@gordonbrander
Copy link
Collaborator

Fixes #34

This should make it impossible to update the state outside the main thread (make it impossible to trigger a purple warning).

Copy link
Collaborator Author

@gordonbrander gordonbrander left a comment

Choose a reason for hiding this comment

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

We should make changes to the approach.

@MainActor var state: Model { get }

func send(_ action: Model.Action) -> Void
@MainActor func send(_ action: Model.Action) -> Void
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rather than isolating send to main actor, we may want to allow send to be nonisolated, and have a separate main-actor isolated transact method which does the actual transaction. This would give us more flexibility in where we can call send, while ensuring state changes only happen on main.

associatedtype Model: ModelProtocol

var state: Model { get }
@MainActor var state: Model { get }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Get-only property should be nonisolated.

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.

Force store state change onto main actor

2 participants