Flutter Mobx:我应该仅使用@Action仅用于更改现有值吗?

发布于 2025-02-06 15:44:56 字数 299 浏览 0 评论 0原文

我正在构建一个具有登录页面的应用,当用户点击按钮时,我想调用登录方法。但是问题是:

我应该仅使用@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤慢歌 2025-02-13 15:44:56

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文