-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: async data loader #6137
feat: async data loader #6137
Conversation
packages/runtime/src/routes.tsx
Outdated
return routeData; | ||
}; | ||
|
||
if (loaderConfig?.[1]?.defer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 1 是干啥的😂
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## release/next #6137 +/- ##
================================================
+ Coverage 81.78% 81.82% +0.03%
================================================
Files 199 199
Lines 17931 18168 +237
Branches 2324 2357 +33
================================================
+ Hits 14665 14866 +201
- Misses 3232 3265 +33
- Partials 34 37 +3
... and 11 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
} | ||
|
||
const loader = appExport?.dataLoader; | ||
const appDataLoaderConfig = appExport?.dataLoader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
空文件 RenderWrapper
} from '../src/routes.js'; | ||
import { useData } from '../src/singleRouter'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint warning
@@ -20,16 +22,16 @@ export interface LoadRoutesDataOptions { | |||
renderMode: RenderMode; | |||
} | |||
|
|||
export function defineDataLoader(dataLoaderConfig: DataLoaderConfig): DataLoaderConfig { | |||
return dataLoaderConfig; | |||
export function defineDataLoader(dataLoader: Loader, options?: DataLoaderOptions): DataLoaderConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果不走 defineDataLoader,那就是数组嵌套了?
const dataLoader = [[() => {}, {}], {defer: ture}]
感觉还是对象会比较清晰
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已调整
dataLoader: async () => ({ type: 'getData' }), | ||
serverDataLoader: async () => ({ type: 'getServerData' }), | ||
staticDataLoader: async () => ({ type: 'getStaticData' }), | ||
dataLoader: { loader: async () => ({ type: 'getData' }) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在的变化是不是有 breakchange,如果不通过 defineDataLoader 的形式指定的话
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以通过兼容 function 或 数组的场景来实现
feat: #6124