mmlpxjs / mmlpx

🐘 mobx model layer paradigm
MIT License
180 stars 10 forks source link

关于ViewModel的一点困惑 #5

Closed xiaodongzai closed 6 years ago

xiaodongzai commented 6 years ago

Page interaction logic definition, live around the component lifecycle, ViewModel instance can not be stored in ioc container.

指的是依赖ViewModel的Compopent unmount后,ViewModel也会被销毁吗?但稍微看了源码(initializers目录下),还是没看明白,是怎么实现的, 它和Store的实现差异在哪里。希望得到大佬的解答。

kuitos commented 6 years ago

store是应用级单例的,通常放属于全局的业务状态,对应mvvm中的model。ViewModel是跟视图绑定,随视图创建销毁的,放局部的视图状态,对应mvvm中的viewmodel

xiaodongzai commented 6 years ago

这个issues有讨论:https://github.com/mmlpxjs/mmlpx/issues/3