update method

void update(
  1. T fn(
    1. T? val
    )
)
inherited

Uses a callback to update value internally, similar to refresh, but provides the current value as the argument. Makes sense for custom Rx types (like Models).

Sample:

 class Person {
    String name, last;
    int age;
    Person({this.name, this.last, this.age});
    @override
    String toString() => '$name $last, $age years old';
 }

final person = Person(name: 'John', last: 'Doe', age: 18).obs;
person.update((person) {
  person.name = 'Roi';
});
print( person );

Implementation

void update(T Function(T? val) fn) {
  value = fn(value);
  // subject.add(value);
}