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

Client details async #90

Open
xeroxstar opened this issue May 31, 2019 · 1 comment
Open

Client details async #90

xeroxstar opened this issue May 31, 2019 · 1 comment

Comments

@xeroxstar
Copy link

Hello,
The client details that returns to the browser after the upload is completed should have return promise also. for example:

let uploader = new siofu();
    uploader.on('saved', async (event) => {
        event.file.clientDetail = new Promise((x) => {
            x({data: 'hello world'});
        })
 });
 uploader.dir = "./uploads";
 uploader.listen(socket);

to solve it i edit few lines in server.js to make it work:

socket.emit(_getTopicName("_complete"), _wrapData({
			id: id,
			success: success,
			detail: typeof fileInfo.clientDetail.then === 'function' ? await fileInfo.clientDetail:fileInfo.clientDetail
}, "complete"));

i think it will be a nice option if we will have this in the module so devs will have more flexible way to work with the data. Anyway, it works great.

@sffc
Copy link
Owner

sffc commented May 31, 2019

Looks good. My only feedback is if you can make this work without the "await" keyword, then the same source can be used on older versions of Node.js. Can you open a PR?

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

No branches or pull requests

2 participants