transloadit / uppy

The next open source file uploader for web browsers :dog:
https://uppy.io
MIT License
29.06k stars 2k forks source link

Make arguments passed to events consistent #3938

Open Murderlon opened 2 years ago

Murderlon commented 2 years ago

Initial checklist

Problem

Event names are sometimes confusing and seem inconsistent.

Solution

@uppy/core

Always send file(s) instead of ID(s)

Renaming we decided not to do. * Rename `files-added` to `file-batch-added`. Or at least a better name to differentiate with `file-added` better * Rename `upload` to `upload-start` * Rename `progress` to `upload-progress` (total progress) * Rename `upload-progress` to `file-progress` (individual progress) * Rename `complete` to `upload-complete` (success or error) * Rename `upload-error` to `file-error` (one file upload error) * Rename `error` to `upload-error` (entire upload error) * Rename `cancel-all` to `upload-cancel`

@uppy/transloadit

Related

These should also be taken into account:

Alternatives

arturi commented 1 year ago

We have internal, non-documented:

stof commented 11 months ago

Reusing the upload-progress and upload-error names for a different event is unfortunate as code that is not properly migrated will still register a listener for an existing event but for a different one.

mifi commented 8 months ago

our file-related events are a bit messy. some include a UppyFile object, other include fileId, some don't include anything.

in a future major we should probably refactor all file related events to either

stof commented 8 months ago

@mifi this could be improved in a minor version by adding the missing property (either fileId or file depending on the choice done for the future) in existing events in addition to the current properties (and documenting that the other one is deprecated)

mifi commented 8 months ago

yes, but it will still be messy because fileId, file etc are not properties, they are instead positional arguments, so some events would be (fileId, file), others (file), others (file, fileId)

Murderlon commented 8 months ago

One way or another I think we would need a breaking change. But I'm starting to change my mind on the renaming of all events. It's incredibly challenging to get right for little user value. Yes the current names are confusing, but with good docs we get away with it and we would prevent breaking changes.

That being said we should definitely make the arguments consistent and up-to-date (no stale file's)

stof commented 8 months ago

@mifi for positional arguments, there is indeed no backward compatible solution.