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

Handle events for the uploader and transcoder better #69

Closed
jellegerbrandy opened this issue Jan 19, 2018 · 2 comments
Closed

Handle events for the uploader and transcoder better #69

jellegerbrandy opened this issue Jan 19, 2018 · 2 comments
Assignees

Comments

@jellegerbrandy
Copy link
Contributor

jellegerbrandy commented Jan 19, 2018

Here is what I think it should look like (I have seen this pattern somewhere but cannot find it, it would be good to have a reference):

uploader.upload(file) shoudl return a Promise (as it already does) that is also an EventEmitter.

So that means that the usage pattern would be something like this:

let foo = uploader.upload(file)
// foo is  a promise that is pedning until uploading and transcoding is finished

i // foo is also an EventEmitter that emits events relative to this upload, that can be subscribed to
foo.on('UploadFinished', dosomething)
foo.on('Progress', function(progress) { console.log(progress })

This is nicer than what we have now (passing callbacks for each event), and just as easy to program (instead of calling onSomething(...args) in the code, we write `promsie.emit('Something', ...args)

@jellegerbrandy
Copy link
Contributor Author

@ya7ya , what do you think?

@ya7ya
Copy link
Member

ya7ya commented Jan 19, 2018

@jellegerbrandy I got it. I'll implement that 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants