Closed subzero911 closed 10 months ago
I got it, I should have just extract observable values in the Observer body and pass it to the function as parameters:
Observer(builder: (_) {
DateTime? verifyAt = task.verifyAt.value;
DateTime? doneAt = task.doneAt.value;
TaskStatus status = task.status.value;
DateTime? deadline = task.endAt;
return Text(
presenter.getDateText(verifyAt, doneAt, status, deadline),
);
});
Here's a problem though, there's a lot of code in the UI layer. It's impossible to move it outside of the Observer body as it won't react then.
I understood. I should do a computation not in the parameter, but in the Observer body.
I have a Text widget which should rebuild. But Observables lie in the nested
getDateText()
function:This function formats observables with DateFormat before printing it.
The only way I've come up with is to perform a fake reading to make the Observer rebuild:
Is there a more correct way in MobX to solve such an issue? Maybe there's some way to manually trigger the Observer?