-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Description
There is @computed.struct, but there is no shallow decorator. But if computed getter returns array it may be really good to shallow compare it!
import { observable, computed, autorun } from "mobx";
class Some {
@observable items = [];
@computed
get actives() {
return this.items.filter((i) => i.active);
}
}
let s = new Some();
autorun(() => console.log(s.actives));
s.items.push({ active: false }); //will recompute actives!Yep, computed.struct will prevent recomputing, but for big arrays of classes it will be unefficient. As I see in https://github.com/mobxjs/mobx/blob/master/src/v5/api/computed.ts it'll be three strings change.