pinafore/src/routes/_components/toast/toast.js

23 lines
460 B
JavaScript
Raw Normal View History

2018-12-22 15:37:51 -08:00
import { importToast } from '../../_utils/asyncModules'
let toast
const lazyToast = {
async say (text) {
if (!toast) {
let Toast = await importToast()
if (!toast) {
toast = new Toast({
target: document.querySelector('#theToast')
})
if (process.env.NODE_ENV !== 'production') {
window.toast = toast // for debugging
}
}
}
toast.say(text)
}
}
export { lazyToast as toast }