Skip to content

Instantly share code, notes, and snippets.

@shiqimei
Last active October 3, 2020 20:24
Show Gist options
  • Save shiqimei/b8be5dc90288285dd9d69fe54d550cec to your computer and use it in GitHub Desktop.
Save shiqimei/b8be5dc90288285dd9d69fe54d550cec to your computer and use it in GitHub Desktop.
// 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