WebediaGaming / react-nexus

Real world apps with React.
483 stars 20 forks source link

Remove MemoryStore.observe() fake onChange notification #64

Closed mrtbld closed 5 years ago

mrtbld commented 5 years ago

Now MemoryStore.observe() doesn't call back right away, following HTTPStore behavior.

The fact that this was done using setImmediate() did not play well with user jest/jsdom testing: the call back would be executed after the test ended, after environment teardown. Which at best was just executing code for nothing and at worst in case of a thrown exception would break the test run (endless waiting loop).

Replace this with an explicit, synchronous state setting at observe() call site: in componentDidMount() of Store wrapper component, as it was already done in componentWillReceiveProps(). This maintains previous behavior but stays in the confines of React lifecycle functions. It doesn't change the fact that two render() may still be performed in sequence, due to state setting triggered after first render().

Remove setimmediate dep because it became unused.