Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model执行时机问题 #51

Closed
chj-damon opened this issue Sep 1, 2020 · 1 comment
Closed

model执行时机问题 #51

chj-damon opened this issue Sep 1, 2020 · 1 comment

Comments

@chj-damon
Copy link

model在应用一启动就会立刻执行。但是我们通常项目里面,后端的接口都是要求要先登录。这样一来,model在应用一启动还没有登录的情况下发请求的话肯定会失败。
所以我的问题是,为什么不把model设计成在某个组件真正使用的时候才触发发请求的动作?

或者,有没有什么办法可以做到在满足某些前置条件的情况下才允许model执行?

@awmleer
Copy link
Member

awmleer commented Sep 1, 2020

model在应用一启动就会立刻执行。但是我们通常项目里面,后端的接口都是要求要先登录。这样一来,model在应用一启动还没有登录的情况下发请求的话肯定会失败。
所以我的问题是,为什么不把model设计成在某个组件真正使用的时候才触发发请求的动作?

或者,有没有什么办法可以做到在满足某些前置条件的情况下才允许model执行?

hox 的设计思路就是全局状态的,如果希望把状态的作用域&生命周期和组件树进行关联的话,目前可以考虑用 reto

@awmleer awmleer closed this as completed Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants