Package Exports
- omi-suspense
- omi-suspense/dist/omi-suspense.es.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (omi-suspense) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
omi-suspense
Handling asynchronous dependencies.
Install
npm i omi-suspenseUsage
<o-suspense
imports={[
import('./components/user-info'),
import('./components/user-profile'),
]}
data={async () => {
return await fetchUserProfile(router?.params.id as string)
}}
onLoaded={(event: CustomEvent) => {
userProfile.value = event.detail[2]
}}
>
<div slot="pending">Loading user profile...</div>
<div slot="fallback">Sorry, we are unable to load the user profile at the moment. Please try again later.</div>
<user-info>
<user-profile></user-profile>
</user-info>
</o-suspense>Custom Render Functions
<o-suspense
imports={[
import('./components/user-info'),
import('./components/user-profile'),
]}
data={async () => {
return await fetchUserProfile(router?.params.id as string)
}}
onLoaded={(event: CustomEvent) => {
userProfile.value = event.detail[2]
}}
beforePending={async (suspense: Component) => {
// do something such as: fade out the root el of custom render
return new Promise((resolve) => setTimeout(resolve, 300))
}}
pending={<div>Loading user profile...</div>}
customRender={(results)=> {
return (
<user-info>
<user-profile></user-profile>
</user-info>
)
}}
fallback={() => {
return <div>Sorry, we are unable to load the user profile at the moment. Please try again later.</div>
}}
>
</o-suspense>License
MIT © OMI