ziko
Version:
A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...
27 lines (26 loc) • 741 B
JavaScript
import {UIElement} from "../mini/UIElement.js";
class ZikoUISuspense extends UIElement{
constructor(fallback_ui, callback){
super({element : "div", name : "suspense"})
this.setAttr({
dataTemp : "suspense"
})
this.fallback_ui = fallback_ui
this.append(fallback_ui);
(async ()=>{
try{
const ui = await callback()
fallback_ui.unmount()
this.append(ui)
}
catch(error){
console.log({error})
}
})()
}
}
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
export{
ZikoUISuspense,
Suspense
}