#Swift #SwiftUI #Concurrency #StateObject #NotificationCenter
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.
https://forums.swift.org/t/deinit-not-called-in-certain-scenarios-with-for-await-loop/64198/19
#swift #swiftui #concurrency #stateobject #notificationcenter
Yesterday we got some important info about how to initialize a StateObject with external values. https://mastodon.social/@lucabernardi/109948882720031817
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.