Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Persist and Upload resolve/reject when download/upload finishes #6

Closed
wants to merge 2 commits into from

Conversation

heyalexchoi
Copy link
Contributor

Most straightforward and obvious use of persist and upload IMO is

// persist something
await persist(path)
// do something with it
await copy(path, destination)

which means you want to know when the upload/download is finished. I modified the way the methods work to resolve / reject when the upload / downloads finish or error.

@vercel
Copy link

vercel bot commented Sep 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-native-cloud-store ✅ Ready (Inspect) Visit Preview Sep 17, 2022 at 11:33PM (UTC)

@XHMM
Copy link
Owner

XHMM commented Nov 14, 2022

Such a long time, 0.8.0 has been released and upload/download now support onProgress option.

If you want to resolve until finished, you can write like this:

await new Promise(async (resolve, reject) => {
  CloudStore.download(path, {
    onProgress(data) {
      if(data.progress === 100) {
        resolve()
      }
    }
  }).catch(reject)
})

@XHMM XHMM closed this Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants