Jaanus Kase · @jaanus
321 followers · 487 posts · Server mastodon.justtact.com

Just ran into a question on how to implement NotificationCenter long-running listeners with modern AsyncSequence API, and have them torn down correctly. This seems to work.

forums.swift.org/t/deinit-not-

#swift #swiftui #concurrency #stateobject #notificationcenter

Last updated 2 years ago

Jaanus Kase · @jaanus
287 followers · 332 posts · Server mastodon.justtact.com

Yesterday we got some important info about how to initialize a StateObject with external values. mastodon.social/@lucabernardi/

Here’s a small exercise I did around that. All the behavior makes sense. You see all the ViewModels are only initialized once.

It’s not clear to me why the documentation uses a closure in example code for “Initialize state objects using external data”. StateObject initializer wrappedValue is already an autoclosure.

#swiftui #stateobject

Last updated 3 years ago