-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Suspense usage #2099
Update Suspense usage #2099
Conversation
Can it be used with components wrapped with renderless components? <!-- Renderless.vue -->
<template>
<slot />
</template> <Suspense>
<Renderless>
<div />
</Renderless>
</Suspense> |
Would it be possible to add a new Composition hook for the cleanup? import { onTimeout } from 'vue'
export default {
setup() {
const { promise, cancel } = asyncRequest()
onTimeout(() => { cancel() })
return promise // will throw on timeout, but that's already handled by Suspense
}
} |
@CyberAP renderless component will work without transition. |
vuejs/core#2099 introduced a big refactoring in how Suspense works, which broke VTU. `SuspenseBoundary` no longer exposes the same interface, so our current implementation was not compiling anymore (and throwing at runtime). This solves the issue and simplifies the current code, as the newly introduced `activeBranch` field now contains the... active branch of the Suspense, so we just have to check that.
Main changes:
<Suspense>
now expects a single root node (cannot be fragment) for the default/fallback slots.An already-resolved suspense only enters "pending state" when the default slot's root node changes.
By default, the current active tree will stay on the screen until the pending tree is resolved. The pending tree, when resolved, replaces the previous active tree and becomes the new active tree.
A
timeout
prop can be specified - if a pending tree remains pending past the timeout threshold, the active tree will be unmounted and be replaced by the fallback tree.New nested async child rendered inside an already resolved suspense no longer puts the suspense into pending state (TODO: components with
async setup()
should be allowed to declare its own loading state / timeout etc. just likedefineAsyncComponent
)@recede
event has been replaced by@pending
and now fires right when a new pending tree is being processed (instead of after the fallback tree is mounted)<Suspense>
can now be used with<transition>
and<keep-alive>
: