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

Known issue #2

Open
winddpan opened this issue Nov 16, 2023 · 1 comment
Open

Known issue #2

winddpan opened this issue Nov 16, 2023 · 1 comment

Comments

@winddpan
Copy link
Owner

winddpan commented Nov 16, 2023

Fixed! a1a8fb1

onAppear mutating doesn't work correctly

Text(person.name)
    .onAppear {
        person.name = "onAppear changed!"
    }

limited by withObservationTracking's behavior, need takes some thinking.

withObservationTracking {
    let _ = person.name
    person.name = "onAppear changed!"
} onChange: {
    print("changed")
    // not called!
}
@beforeold
Copy link

beforeold commented Nov 17, 2023

我刚好遇到了一个类似的问题

这里不生效,是因为 onAppear 的 closure 是 escaping 的,将会被异步调用,不会被监听到。

我的问题是类似的,用到了 ForEach 这个类型,在 ForEach 的 closure 里面的 subview 访问 model 的属性 propertyA,subview 同样无法得到 propertyA 变更的刷新

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

No branches or pull requests

2 participants