Skip to content

Instantly share code, notes, and snippets.

@kagaya85
Last active May 9, 2019 18:42
Show Gist options
  • Save kagaya85/cb5995219bd6aa7a1664b69264e238f6 to your computer and use it in GitHub Desktop.
Save kagaya85/cb5995219bd6aa7a1664b69264e238f6 to your computer and use it in GitHub Desktop.
将旧API封装成Promise对象的方法
// 已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