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

Add progress callback #2

Merged
merged 2 commits into from
Sep 12, 2015
Merged

Conversation

AndreLion
Copy link
Contributor

- 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)){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file.progress 这个 callback 可以通过什么方式传进来?

Copy link
Contributor Author

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()方法

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯, 我在考虑直接返回这个 request 对象, 这样的话 不仅可以用 on 来获取 progress, 而且也可以用 .promise()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

赞,持续关注中...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

试了一下,返回 request 只能拿到上传完成后的值 100%, 拿不到变化的值,还是用 callback 的方法吧 :)

lenage added a commit that referenced this pull request Sep 12, 2015
@lenage lenage merged commit f817a60 into lenage:master Sep 12, 2015
@lenage
Copy link
Owner

lenage commented Sep 12, 2015

Thanks @AndreLion , even we have callback now, but it still doesn't work well, i will fix it later

@AndreLion
Copy link
Contributor Author

npm上的代码什么时候会生效呢?还需要 @lingochamp 来操作吗?

@lenage
Copy link
Owner

lenage commented Sep 12, 2015

不需要, 我马上会发一个新版本 0.3.0

@lenage
Copy link
Owner

lenage commented Sep 12, 2015

@AndreLion npm 上的已经是最新的版本了,另外你也可以在 http://lenage.com/react-qiniu/ 看看 demo,
Demo 里面会实时的显示上传进度

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

Successfully merging this pull request may close these issues.

2 participants