WebediaGaming / react-nexus

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

[Fix] Fix state desync in HTTPStore #65

Closed dorian-marchal closed 4 years ago

dorian-marchal commented 4 years ago

In order for fetch to be awaitable, the forceFetch promise must be up to date. This wasn't the case before this commit: observe triggered a forceFetch without sharing its promise. In this case, fetch couldn't return the forceFetch promise which resulted in desync: the store state was "pending" but fetch didn't return a promise.

Fixes this by saving the forceFetch promise in observe (the same way it was already done in fetch).