Comments (6)
如果是这样的话,initialState也要改为
initialState(){
return {
name:"",
age:1
}
}
from foca.
模型多的情况下确实可能出现这个问题。尤其是在RN这种把所有JS打包在一起的。
对于webpack或者vite打包的web项目则不存在这个问题,因为模型本身就是模块化的,支持代码分割
,即自动分配到对应页面的chunk里了。
即用即创建,由于用户视口有限,同时在线的model的数量是很少的。
这是个很不错的建议,感谢你的付出。实现上我觉得应该让开发者无感知,getModel(userModel).state.name
这种方式太繁琐,所有地方都要加,增加了开发者的心智负担。我觉得可以借鉴linux Copy on Write
的思路,我们实现一种Register on Read
的机制,即在部分属性入口自动判断是否需要注册。
from foca.
最近在完善node框架,所以应该会到9月才会开始升级
from foca.
昨晚实现了按需初始化模型的功能并发布了 1.3.0-next.0
版本,3342275 ,用户无感知,但仍需多测试一下,欢迎给予意见建议
from foca.
大概思路是在一些入口增加逻辑判断,比如执行actions(reducers)、获取state、使用useModel等。
from foca.
如今有了更好的选择,局部模型。 https://foca.js.org/#/advanced?id=%e5%b1%80%e9%83%a8%e6%a8%a1%e5%9e%8b
from foca.
Related Issues (20)
- Cannot find namespace 'NodeJS' HOT 3
- tarojs/components 组件标红! HOT 9
- add support of undefined type in initialState HOT 4
- 如何在modelA里访问modelB的数据? HOT 4
- 使用时出现action in action的小问题 1.0.0 HOT 23
- 一定要在 effects 中使用 this.setState 或者 先定义 actions 方法调用才能更新状态吗 HOT 6
- 关于持久化的版本号 HOT 7
- 多个loading的情况 HOT 1
- [Improvement] reset的特性无需深拷贝 HOT 3
- [New Feature]响应式 支持对复杂对象的支持 HOT 2
- initialState参数很多,如何一次性setState更新? HOT 3
- actions,异步actions, reducer, methods, computed, watch 名称叫法 HOT 1
- 如何动态删除指定的缓存? HOT 1
- foca 2.0 规划
- 持久化没有把initvalue放进去 HOT 3
- onInit不会触发useLoading HOT 2
- taro 支付宝小程序不支持吗? HOT 9
- foca2 在低版本的手机有兼容问题,iphone6和部分oppo HOT 9
- 有办法删除Model吗? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foca.