-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Problem: Last onFileAdd wins #572
Comments
Hey – thanks for reporting Yes 😅 I'm afraid you're right, although I'm not sure about the I (maintainer, but not original author) just recently noticed this when migrating to Octane in #514
Since you asked.
If we can get a fix staged for this we can release it for you as a If you're interested I would welcome a PR to solve this 🙇🏻 if not I'll try and get to it soon(™️) Steps I would take:
|
Thanks @gilest for your answer
Yes, you are right, I mean About your suggested solution:
Whilst technically feasible, this wouldn't make the components API work. If there are three components and an upload is triggered in one location, then all callbacks would be invoked. That may be ok by design (because at least the owerwrite wouldn't happen any longer), yet wouldn't fit my particular use-case ... and both are somewhat valid :D It's a tricky piece of an API, I must admit - better not make a shot from the hip and give it some thought instead. I see there are three levels at which you want to interact:
I think, it is ok to ignore superglobal here and think about the interaction of global and local. It should be explicit if I add callbacks to queue or ui element. Depending on where I add that one, it will react accordingly. Adding a callback to the queue, will always notify me whenever anything is happening in that queue. Addding a callback to the UI element will only notify me when anything from the UI element is happening. The UI element will still add elements to its associated queue, but will only get notified back, if this is from the same origin. That's my understanding? That's how I'd interact with those mechanics, as this is how the rest of the ember ecosystem works. Please verify or make comments onto that. If this is valid, then we can think about an API design =) Interesting topic that came up =) Also hit me up on discord if you prefer. |
Right – I didn't completely understand your use-case (and was a little mislead by the title of the issue). My suggestion was to fix a bug in the current API (the callbacks overwriting each other) because I thought it would unblock you before the new API is rolled out. New API has component and queue callbacks planned. |
Amazing, thank you. Will give it a try next week. |
Hey,
in my current screen I'm developing, I have two UI locations where I am triggering an upload and a third location, that is showing the upload (and has an upload as well). In short, the code is looking like this:
You may realize, there are
firstUploadHandler
,secondUploadHandler
andthirdUploadHandler
. That is, I want to give feedback about the upload in the respective locations. Let's say, user decided to use location 1 for upload, I wanna show progress there. If user decided to use location 2 for upload, I want to show progress over there and so forth.And this is where the problem comes in. All locations operate on the same queue, which is intended. Each
<FileUpload>
component will overwriteonFileAdd
in the queue with the value from@onClick
, means the last@onClick
wins. Which is, if location 1 is used for uploading, thethirdUploadHandler
is triggered.That comes with a problem, meaning the
@onClick
component is not bound to the component, but the queue and the@onClick
cannot be trusted to work "as intended". I've seen in #316 that this will likely improve it, by properly connecting it to the queue through the helper, I think that's the much better API. I can only guess, that the queue is taking over the responsibility of transmitting the file, while a component - such as<FileSelect>
with the@onSelected
argument is there for handling UI responsibility? Am I reading this correctly and is this expected to come?What would be my best options to handle this with v4 right now?
The text was updated successfully, but these errors were encountered: