ant-design/components/message/demo/thenable.md
Jinxuan Zhu c2519e776b Add promise-like interface (#10470)
* Add promise-like interface

* Keep hide interface

* Shorten

* Test Promise

* Update document

* Update demo: 2.5 second is insignificant with the default 3s hiding

* Update demo: then  interface

* Fix line break

* Chainable

* Thenable demo

* Thenable test

* Fix tsc error

* Fix tsc error

* Better document

* Revert change in loading.md

* Change snapshot
2018-05-25 20:41:07 +08:00

725 B

order title
5
zh-CN en-US
Promise 接口 Promise interface

zh-CN

可以通过 then 接口在关闭后运行 callback 。以上用例将在每个 message 将要结束时通过 then 显示新的 message 。

en-US

message provides promise interface for onClose. The above example will display a new message when old message is about to finish.

import { message, Button } from 'antd';

const success = () => {
  message.loading('Action in progress..', 2.5)
    .then(() => message.success('Loading finished', 2.5))
    .then(() => message.info('Loading finished is finished', 2.5));
};

ReactDOM.render(
  <Button onClick={success}>Display a sequence of message</Button>
, mountNode);