update method
void
update(
- void fn(
- 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(void Function(T? val) fn) {
fn(_value);
subject.add(_value);
}