sindresorhus / Plash

💦 Make any website your Mac desktop wallpaper
https://sindresorhus.com/plash
MIT License
3.46k stars 128 forks source link

SwiftUI question #143

Closed godbout closed 11 months ago

godbout commented 11 months ago

just curious about your code. it's obviously beautiful and i'm 100% certain that you know way more than me what you're doing. and i'm trying to learn from the best. so. the question: what's the advantage of using a @StateObject that holds the AppState singleton rather than just using the singleton directly within the SwiftUI views?

hope my question makes sense. thanks in advance for the time you may spend on this.

sindresorhus commented 11 months ago

Future-proofing. If I add any @Published properties, it will just work without having to change a lot of code.

godbout commented 11 months ago

thank you Sir. makes total sense. i don't have much SwiftUI stuff in my apps (just the Settings) so yeah, didn't catch this. kòp kun kráp!