Last active
October 3, 2020 20:24
-
-
Save shiqimei/b8be5dc90288285dd9d69fe54d550cec to your computer and use it in GitHub Desktop.
This file contains 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
// Last updated: Sun Oct 4 04:22:51 CST 2020 | |
const MiniApp = new Promise(resolve => { | |
if (window.MiniApp) { | |
resolve(window.MiniApp); | |
} | |
const id = setInterval(() => { | |
if (MiniApp in window) { | |
clearInterval(id); | |
resolve(window.MiniApp); | |
} | |
}, 100); | |
}); | |
// usages | |
MiniApp.then(console.log); | |
// or | |
(async () => { | |
const miniApp = await MiniApp; | |
console.log(miniApp); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment