Is it a wrong practice to make all viewModels singleton if you don't need multiple instances of each screen?
Yes because singletons are evil.
You will probably run into issues where the VMs are holding onto state which could be out of sync with your database and lead to excessive memory consumption. It will be much harder to unit test due to the state being persisted.
Singletons:
So only use the singleton pattern if you have a very good reason to do so - "because you can" is not a good reason.
Yes.
First, you may very well be putting yourself in a corner for any extensibility, depending on the singleton implementation. Second, the design probably won't be very clean referring to static singletons everywhere. Third, unit testing will either be difficult or it won't replicate actual class usage, or both. Forth, do having singletons solve any design problems for you? If you are simply trying to save on resources then I would just forget it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With