Search code examples
flutterdartmobx

Flutter MobX: Should I use @action just only for changing the existing value?


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
}

Solution

  • 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.