-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add progress callback #2
Conversation
- source of isFunction() : http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascri pt-variable-is-function-type - replace file.progress property with a callback
@@ -102,11 +103,20 @@ var ReactQiniu = React.createClass({ | |||
.field('x:size', file.size) | |||
.attach('file', file, file.name) | |||
.set('Accept', 'application/json') | |||
.on('progress', function (e) { file.progress = e.percent;}) | |||
.on('progress', function (e) { | |||
if(me.isFunction(file.progress)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file.progress
这个 callback 可以通过什么方式传进来?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在onDrop()拿到files对象的时候,可以给每个file定义.progress(),其实也就是把之前的progress属性变成了progress()方法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯, 我在考虑直接返回这个 request
对象, 这样的话 不仅可以用 on
来获取 progress, 而且也可以用 .promise()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
赞,持续关注中...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
试了一下,返回 request 只能拿到上传完成后的值 100%, 拿不到变化的值,还是用 callback 的方法吧 :)
Thanks @AndreLion , even we have callback now, but it still doesn't work well, i will fix it later |
npm上的代码什么时候会生效呢?还需要 @lingochamp 来操作吗? |
不需要, 我马上会发一个新版本 0.3.0 |
@AndreLion npm 上的已经是最新的版本了,另外你也可以在 http://lenage.com/react-qiniu/ 看看 demo, |
http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type