Last active
May 9, 2019 18:42
-
-
Save kagaya85/cb5995219bd6aa7a1664b69264e238f6 to your computer and use it in GitHub Desktop.
将旧API封装成Promise对象的方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 已setTimeout为例 | |
const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
// 调用 | |
wait(1000).then(() => { | |
// do something | |
}); | |
// 这样回调起来就舒服多了 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment