Skip to content Skip to sidebar Skip to footer

Make Single MobX Autorun Or Reaction For Observable Property Of All Objects In Array

I have class with @observable (all examples are Typescript/pseudocode) class Page { id: number = 0; @observable isVisible: boolean = false; } let array = [new Page(), ne

Solution 1:

If the reaction is responsible for sending the the update of an individual page, I would setup that reaction in the Page constructor itself or have a utility function in Page for that, so that you don't have to keep your pages array in sync with your reaction disposers array (but as best practice, do dispose the reaction if you want to delete the page)


Post a Comment for "Make Single MobX Autorun Or Reaction For Observable Property Of All Objects In Array"