Flutter Mobx:我应该仅使用@Action仅用于更改现有值吗?
我正在构建一个具有登录页面的应用,当用户点击按钮时,我想调用登录方法。但是问题是:
我应该仅使用
@Action
仅用于更改现有值?
还是我可以做这样的事情:
@action
void login() {
... // here is the business logic
}
I'm building an app which have a Login page, and I wanna call a login method when the user taps the button. But the question is:
Should I use the
@action
just only for changing the existing value?
Or can I do something like this:
@action
void login() {
... // here is the business logic
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
mobx是状态管理,因此是所有关于管理状态的。
状态是随着时间变化的数据,因此在这里进行MOBX操作应该使实际状态/数据更改,否则它应该是正常函数而不是状态行动。
mobx is a state management, so it is all about managing state.
State is data that changes over time, so here making mobx action it should make a real state/data change otherwise it should be a normal function not a state action.