Code Monkey home page Code Monkey logo

Comments (6)

yoavniran avatar yoavniran commented on June 1, 2024 1

I wouldnt like to expose the uploader instance unless there's a very strong case for it

In any case, Ive a solution I believe will work nicely. Abort will take care of pending uploads and Uploady context will have the clearPending method available.

This way you'll be able to cancel individual (pending) uploads or all of them together

from react-uploady.

yoavniran avatar yoavniran commented on June 1, 2024

@LukasOchmann is this the actual code youre using?
the hooks you use in this code are outside the context provider. So this wont work.

You should actually be getting an error.

If this isnt the actual code, please provide an updated version or codesandbox

from react-uploady.

LukasOchmann avatar LukasOchmann commented on June 1, 2024

It is an reduces version. My Example was wrong.

from react-uploady.

LukasOchmann avatar LukasOchmann commented on June 1, 2024

@yoavniran i created a Sandbox: https://codesandbox.io/s/vibrant-cdn-b25h6?fontsize=14&hidenavigation=1&theme=dark

from react-uploady.

yoavniran avatar yoavniran commented on June 1, 2024

There are a few things going on here:

  • Currently abort cannot be used on items that are not already uploading.

  • There is currently no way to clear pending uploads (autoUploads = false) from the UI components. The Uploader instance does have a clearPending method but its not exposed to the UploadyContext API.

  • clearPending doesnt have the granularity to remove a single item, only all pending batches

  • there's a bug in your codesandbox, line 43, youre calling the abort method when passing it to the button onClick instead of when the button is clicked. This wont work of course but Im guessing its just a mistake in the sandbox and not your actual code.

  • even if everything worked as you need. You would need to remove the aborted file from your UI (files state). Probably using using the abort event listeners.

With all that in mind, I will need to think of a way to make it easy to remove pending batch items. I think modifying the abort methods is the best approach since it will make it a single flow instead of having implementations decide which flow to use based on internal Uploader state. WDYT?

I will look into adding this as a feature soon.

from react-uploady.

LukasOchmann avatar LukasOchmann commented on June 1, 2024

Thank you for your Response and for accepting it as an enhancement,

yes line 43 was a mistake, i was in a hurry....

i also prefer an solution wich modifies the abort method. With an extra method for that usecase i had to evaluate the current files state instead of simply aborting it.

As an alternativ to exposing the Uploder instance, could the Uplody take a prop "instance" wich takes in an custom Uploder Instance? or maybe an higher order Component withCustomUploder

from react-uploady.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.