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 promise-like interface #10470
Add promise-like interface #10470
Conversation
Deploy preview for ant-design ready! Built with commit f5fe409 |
Codecov Report
@@ Coverage Diff @@
## feature-3.6.0 #10470 +/- ##
=================================================
+ Coverage 86.51% 87.85% +1.34%
=================================================
Files 196 194 -2
Lines 4798 4760 -38
Branches 1340 1329 -11
=================================================
+ Hits 4151 4182 +31
+ Misses 644 574 -70
- Partials 3 4 +1
Continue to review full report at Codecov.
|
4e1ad87
to
3db4e55
Compare
</div> | ||
), | ||
onClose, | ||
const closePromise = new Promise((resolve) => { |
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.
I am not sure. Do you mean some browsers ant-design supporting does not support 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.
I think it's ok, never mind.
// calculate the approximately duration value | ||
const aboutDuration = parseInt((Date.now() - now) / 1000, 10); | ||
expect(aboutDuration).toBe(defaultDuration); | ||
done(); | ||
}); | ||
}).then(() => true); | ||
}); |
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.
Write a separator test case.
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.
Fixed. Thank you.
components/message/index.zh-CN.md
Outdated
@@ -35,6 +35,12 @@ title: Message | |||
- `message.config(options)` | |||
- `message.destroy()` | |||
|
|||
组件同时提供 then 接口 |
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.
then 改成 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.
加一个空行。
components/message/index.zh-CN.md
Outdated
@@ -35,6 +35,12 @@ title: Message | |||
- `message.config(options)` | |||
- `message.destroy()` | |||
|
|||
组件同时提供 then 接口 | |||
- `message[level](content, [duration] ).then(afterClose)` | |||
- `message[level](content, [duration], onClose ).then(afterClose)` |
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.
onClose 后面多余空格。
components/message/index.zh-CN.md
Outdated
- `message[level](content, [duration] ).then(afterClose)` | ||
- `message[level](content, [duration], onClose ).then(afterClose)` | ||
|
||
其中`message[level]` 是组件已经提供的静态方法。`then` 接口返回值是 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.
`message 前端少了一个空格。
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.
句尾加标点。
再补充一下用例吧。 |
@afc163 请问建议补充怎样的用例呢? |
测试 promise 用法有效并符合预期。 |
@afc163 请问你指的是这个 PR 中的 |
components/message/demo/loading.md
Outdated
@@ -19,7 +19,7 @@ import { message, Button } from 'antd'; | |||
const success = () => { | |||
const hide = message.loading('Action in progress..', 0); | |||
// Dismiss manually and asynchronously | |||
setTimeout(hide, 2500); | |||
setTimeout(hide, 500); |
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.
No need to change this.
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.
I revert the change in recent commit 799bcfb. Thank you.
Description
#10421
This PR provides the then(onClose) promise-like interface for the message
Check List
Please makes sure that these checkboxes are checked before submitting your PR, thank you!
master
, feature for latest active branchfeature-x.x
.npm run lint
and fix those errors before submitting in order to keep consistent code style.Extra checklist:
elif isNewFeature :