MVVM的ViewModels辛格尔顿格尔、MVVM、ViewModels

由网友(冬日傲娇的菊)分享简介:这是一种错误的做法,使所有的ViewModels单身,如果你不需要每个屏幕的多个实例?Is it a wrong practice to make all viewModels singleton if you don't need multiple instances of each screen?推荐答案是的...

这是一种错误的做法,使所有的ViewModels单身,如果你不需要每个屏幕的多个实例?

Is it a wrong practice to make all viewModels singleton if you don't need multiple instances of each screen?

推荐答案

是的,因为的单身是邪恶的。

您可能会碰到那里的虚拟机都抱着到状态,这可能是与你的数据库不同步而导致内存消耗过大的问题。 这将是更难单元测试,由于国家正在持续。

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.

阅读全文

相关推荐

最新文章