OT: State Management with Flutter - Something seems familiar here

After watching a video about state-management in flutter, I checked out MobX and it’s “cool code gen feature” and guess what that does…?

It replaces

class Counter {
  Counter() {
    increment = Action(_increment);
  }

  final _value = Observable(0);
  int get value => _value.value;

  set value(int newValue) => _value.value = newValue;
  Action increment;

  void _increment() {
    _value.value++;
  }
}

with

import 'package:mobx/mobx.dart';

part 'counter.g.dart';

class Counter = CounterBase with _$Counter;

abstract class CounterBase with Store {
  @observable
  int value = 0;

  @action
  void increment() {
    value++;
  }
}

:grin:

1 Like

What is the point of that post? Sorry if I’m missing some context as I don’t know Aurelia well.

Is this similar to something Aurelia does right out of the box?

1 Like

Sorry, can’t remember.
But observing changes in local state in Aurelia is quite powerful and comes right out of the box.
And registering actions with your store…well, not that elegant, but you could roll your own decorator easily.

1 Like