optimizely / nuclear-js

Reactive Flux built with ImmutableJS data structures. Framework agnostic.
https://optimizely.github.io/nuclear-js/
MIT License
2.23k stars 141 forks source link

An edge case where the observer watches any store might keep returning the old cached value as time advances. #188

Closed lyonlai closed 9 years ago

lyonlai commented 9 years ago

We ran into a problem where an observer for any store might not be working when the store is registered later. In our specific case, the global observer register before the other store kicks in later. But after given a bit of thought, this might be a general case where it will happen the case where a store is registered later than the any store observer.

here's the show case in js fiddle. https://jsfiddle.net/lyonlai1984/dhxx780m/5/

In the test case, when you click the increment button. you will see the notifier column doesn't move.

I've found the problem is actually in isCached function. I think it should really do the store dependency checks for the getter of any store.