unistore icon indicating copy to clipboard operation
unistore copied to clipboard

Fix broken example in the README.md

Open boazberman opened this issue 7 years ago • 3 comments

In the example store.setState was called with what could be a stale state. In order to use the current state, one must call store.getState. Similar to how in React if you call setState without a callback it is a potential bug.

boazberman avatar Jun 16 '18 17:06 boazberman

I've spent a lot of time searching for this API, and only found it in the declaration file. If I'm mistaking for it's need, I would be more then grateful to learn.

boazberman avatar Jun 16 '18 17:06 boazberman

I believe there's another example that shows the getState() version - perhaps we'd be better off showing a synchronous function for this example? I just wanted to have a way to show both.

developit avatar Aug 29 '18 15:08 developit

Well, my difficulty was that I just could not understand how one can manipulate the state object after an async operation happened, and expect the results to be valid, as the state could change during that period, but the state object being manipulated is the old state. If you think there is no need in this example I understand, I just though it will save some people from having bugs caused by an asynchronous behavior. Thanks!

boazberman avatar Aug 31 '18 08:08 boazberman