fix(core): expose catched editor load error (#5133)

This commit is contained in:
Joooye_34
2023-11-29 20:31:35 +08:00
committed by GitHub
parent 908c4e1a6f
commit a226eb8d5f
3 changed files with 21 additions and 30 deletions
@@ -96,11 +96,18 @@ export class NoPageRootError extends Error {
}
}
/**
* TODO: Defined async cache to support suspense, instead of reflect symbol to provider persistent error cache.
*/
const PAGE_LOAD_KEY = Symbol('PAGE_LOAD');
const PAGE_ROOT_KEY = Symbol('PAGE_ROOT');
function usePageRoot(page: Page) {
if (!page.loaded) {
use(page.load());
let load$ = Reflect.get(page, PAGE_LOAD_KEY);
if (!load$) {
load$ = page.load();
Reflect.set(page, PAGE_LOAD_KEY, load$);
}
use(load$);
if (!page.root) {
let root$: Promise<void> | undefined = Reflect.get(page, PAGE_ROOT_KEY);