Hi,
Could you consider make the workers listen also to changes in attributes of custom objects?
It works so good with strings, double, etc. But when the observable is a custom object, it doesn't work.
Works: =========================
class HomeController extends GetxController {
final acuCtrl = .0.obs;
@override
void onInit() {
debounce(
acuCtrl,
(_) => print("debouce$_"), time: Duration(seconds: 1));
super.onInit();
}
}
: =========================
Doesn't work (// Doesn't trigger when simulaDados.value.attribute1 or simulaDados.value.attribute2 changes...)
class HomeController extends GetxController {
Rx
void onInit() {
debounce(
simulaDados,
(_) => print("debouce$_"), time: Duration(seconds: 1));
super.onInit();
}
}
Oi Jonatas, tem como fazer os workers ouvirem tamb茅m mudan莽as de atributos de minha classe? 脡 que no meu projeto n茫o tem muita vari谩vel "solta" no controller, a maioria fica em objetos.
(PS.:Parab茅ns, Jonatas, o GetX mudou meu astral para lidar com Flutter!)
I'm sure it works well .
class TestController extends GetxController{
var count = 0.obs;
final user = User().obs;
//the first way to update user
changeUserOne(){
user.update((val) {
val.name = 'John';
val.age = 18;
});
}
//the second way to update user
changeUserTwo(){
user(User(name: "Tick",age: 35));
}
@override
void onInit() {
// TODO: implement onInit
super.onInit();
debounce(
user,
(value){
print("debounce finish : ${value.name} || ${value.age}");
},
time: Duration(seconds: 1)
);
}
}
// model
class User{
User({this.name = "",this.age = 0});
String name;
int age;
}
Most helpful comment
I'm sure it works well .