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

actions,异步actions, reducer, methods, computed, watch 名称叫法 #29

Closed
SoonIter opened this issue Jul 29, 2022 · 1 comment
Closed

Comments

@SoonIter
Copy link

effects这个词,给我的感觉更多是副作用,类似watch监听导致的watchEffect,或者是useEffect产生的副作用。如果watch特性上线,应该给effect换名的。
我的提议是把异步action放到actions,不知道判断一下返回值为Promise可不可以实现。

@SoonIter SoonIter changed the title 异步actions可不可以在actions里然后自主识别 异步actions可不可以在actions里通过返回Promise自主识别 Jul 29, 2022
@geekact
Copy link
Member

geekact commented Jul 29, 2022

actions在部分状态库中叫 reducers,叫法上后者比较贴切;
effects确实提供了副作用的功能,比如 setState,比如 loading
而watch特性应该会直接开一个watch属性;
至于普通的返回,其实更应该叫做methods,只不过effects也能返回数据,所以就合并在一起了。

这个问题我也想了挺久,也参考了其他库的规范,但是没有统一的定论。

命名这块,可谓仁者见仁。后期可能会修改的方案:

  • actions -> reducers
  • effects -> methods

@SoonIter SoonIter changed the title 异步actions可不可以在actions里通过返回Promise自主识别 actions,异步actions, reducer, methods, computed, watch 名称叫法 Aug 31, 2022
@geekact geekact closed this as completed Nov 10, 2022
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