3 ms·
Something like the observer pattern: https://en.wikipedia.org/wiki/Observer_pattern#JavaScript https://en.wikipedia.org/wiki/Observer_pattern#JavaScript If yo
by LAC-Tech 5y ago
Something like the observer pattern:
https://en.wikipedia.org/wiki/Observer_pattern#JavaScript https://en.wikipedia.org/wiki/Observer_pattern#JavaScript
If you look at it from another angle, you might see that `setState` could take a function oldState => newState instead of a raw value. Then you have a `reducer` in the sense of redux.
You could also just make the list of observers functions, instead of objects with the signal method.
All easily done in about 20 LOC.