Skip to content
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

Fix bug where changes are published during SwiftUI view init #74

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

mjarvis
Copy link
Owner

@mjarvis mjarvis commented Jun 20, 2023

Resolves #73

Warning on Context's @Published var parameters: Publishing changes from within view updates is not allowed, this will cause undefined behavior.

This is due to assigning values into parameters during the view creation:

Foo(
    context.parameter(name: "bar", defaultValue: "some") // This causes `objectWillChange.send()` due to `@Published`
)

Resolves #73

Warning on `Context`'s `@Published var parameters`:
`Publishing changes from within view updates is not allowed, this will cause undefined behavior.`

This is due to assigning values into `parameters` during the view creation:
```
Foo(
    context.parameter(name: "bar", defaultValue: "some") // This causes `objectWillChange.send()` due to `@Published`
)
```
@mjarvis mjarvis enabled auto-merge (squash) June 20, 2023 18:09
@mjarvis mjarvis merged commit 82035f9 into main Jun 20, 2023
5 checks passed
@mjarvis mjarvis deleted the mjarvis/73-SwiftUI-published-warning branch June 20, 2023 18:16
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.

SwiftUI publishing changes warning
2 participants