DEV Community

loading...

Discussion on: Angular State Management Without RxJS - An Experiment

Collapse
zwacky profile image
Simon Wicki

Really great write up! πŸ‘
You piqued my interest in how the stencil store notifies the component that it has changed

Collapse
daviddalbusco profile image
David Dal Busco Author

Thank you Simon πŸ™.

I am curious about it too I have to say. Spontaneously I tend to think that changes are notified because the store is a proxy, but I can be fully wrong.

Collapse
ribizlim profile image
Mark Magyarodi

Ok, please do one more experiment for us: on page2 create a button to change the store, set the card component to onPush, and I bet there will be no update of the numbers in the card...

Thread Thread
daviddalbusco profile image
David Dal Busco Author

Indeed did that experiment earlier this evening, if all components' change detection are set to OnPush and the components are away from the click event, then it wasn't automatically re-rendered.

For such case I would have to hook on onChances and triggers or mark the change detection.

Afterwards I improved this test by using the store directly in the template instead of the state. The first value pushed in the store did not trigger the re-rendering but any following update to the store were actually detected as changes.