question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC make `persistStore` return `persistor` in a promise

See original GitHub issue

First, 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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
darsaincommented, Nov 27, 2016

👍 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:

const persistor = persistStore(store, config); // drop the callback, and don't auto-load

// explicit load
persistor.load(callback); // calls the callback
persistor.load();         // returns promise

// fully controlled purge, can be called before or after loading
persistor.purge();
0reactions
aguynamedbencommented, Dec 22, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found