RFC make `persistStore` return `persistor` in a promise
See original GitHub issueFirst, love the repo, it’s magic!
I’ve got 2 sources of data: 1 comes down from the server, and another is stored locally. I get both together & then start the app (in this case, call my router).
Putting all my router logic in the callback function works, but I’d love it if the persistor was returned in a promise, after all, it’s not like we could really use it before the data is rehydrated anyways, right?
That way, we could get rid of the callback and just write something like:
const persistor = await persistStore()
if folks don’t use the persistor, then there’s no breaking change.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React RFC: First class support for promises and async/await
In the RFC, I see that the only example is given for handling promises. I'm wondering whether it is ok to make 'use'...
Read more >console.error: "redux-persist failed to create sync storage ...
How to solve: console.error: "redux-persist failed to create sync storage. ... render() { const persistor = persistStore(store); return ...
Read more >'browserrouter' cannot be used as a jsx component - You.com
Here two way to create a component in React. 1-) Function Components must be like following: function Welcome(props) { return <h1>Hello, {props.name}</h1>; }....
Read more >Redux-persist: The Good parts - codeburst
export const persistor = persistStore(store) persistor.purge(). This is because purge returns a promise, not the persistor, as I learned here.
Read more >[RFC] New Promise Binding - Development - ReScript Forum
The bindings can be installed alongside your existing Js.Promise code. ... How to create a function with a Promise and return data to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

👍 the current API is awkward to use and makes the code ugly. I see no reason why I’d want to purge the store while it’s loading. I would assume that would break something.
What actually might be useful is a way to only purge with no loading (i.e. purge previously saved state). That is not supported right now as far as I’m aware. The API would look something like this:
This hasn’t been responded to in a long while, so I’m going to mark it as stale. Please feel free to continue the conversation and I’ll reopen.