Does it make sense to use a normal class as a View...
# compose-desktop
s
Does it make sense to use a normal class as a ViewModel since desktop apps usually don’t need lifecycle awareness? I really like ViewModels as an architectural pattern.
👍 1
p
I think lifecycle awareness is needed in all platforms.
1
a
It makes sense if you think you should separate logic from the UI.
s
Do you think I’ll face any problems if I don’t consider lifecycle awareness?
p
Resource leakage in general. Depends on the type of App obviously. If your App doesn't consume much network in the background you are fine not using it
a
There’s no lifecycle you really need to consider
Your viewmodel will not be saved and restored when the app restarts, and as long as it’s alive, your viewmodel is alive.
☝🏼 1
☝️ 2
s
Oh thanks!
a
We use Viewmodels in out Compose HTML app and it works great. It is a great abstraction
s
What do you mean by HTML app? Sorry I don't have much idea about it. I would like to know what is it?
a
The Compose HTML version. Not desktop and not web. Same runtime, different target
s
Ohh got it!
Thanks
👍 1