⚠️ I forgot an important piece of information! AsyncStream will be back ported to iOS 13 in Xcode 13.2, which is currently in beta. So right now if you use Xcode's latest stable version (Xcode 13.1), you'll notice that AsyncStream is iOS 15 only, and that's totally normal.
Would be nice to have a follow on video, starting with the code you have in this video, to add a button to stop the number generator - to show cleanest way how to suspend or even end a task.
Pretty cool. Only being able to retain the generator because of the onTermination closure is pretty weird. Rust handles this kind of pattern using `move` to give ownership of a variable into a new context. Seems like it might be handy in Swift!
Great video! I saw that you use the async stream in a task closure in the content view struct. Ideally we don’t want too much logic in the view. Nice thing about Combine is that all the observation logic can go into an ObservableObject class and it writes into a @Published var, and view just has to display that published var from the @ObservedObject. Can async/await do the same? (Let the for await code be in a separate class and the view just displays a var without having any observation logic)
⚠️ I forgot an important piece of information! AsyncStream will be back ported to iOS 13 in Xcode 13.2, which is currently in beta. So right now if you use Xcode's latest stable version (Xcode 13.1), you'll notice that AsyncStream is iOS 15 only, and that's totally normal.
Once again great topic, amazing content. Thanks Vincent!
Would be nice to have a follow on video, starting with the code you have in this video, to add a button to stop the number generator - to show cleanest way how to suspend or even end a task.
Good idea!
Pretty cool. Only being able to retain the generator because of the onTermination closure is pretty weird. Rust handles this kind of pattern using `move` to give ownership of a variable into a new context. Seems like it might be handy in Swift!
Doesn’t follow the principle of separation of concerns. They really should have a separate modifier to hold/retain the reference.
Wow ! migration to my project now.
Another great video. 🚀🚀🚀 Question: Why did you choose for NumberGenerator to be a class instead of a struct?
I think it’s because it manages a Timer therefore it needs to be able to mutate itself.
Great video! I saw that you use the async stream in a task closure in the content view struct. Ideally we don’t want too much logic in the view. Nice thing about Combine is that all the observation logic can go into an ObservableObject class and it writes into a @Published var, and view just has to display that published var from the @ObservedObject. Can async/await do the same? (Let the for await code be in a separate class and the view just displays a var without having any observation logic)
Good point! Yes of course, in a real app I would definitely recommend introducing a few model later such as the one you described 👍
Holymoly!!! 😭👍