Skip to content
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

Merged
merged 43 commits into from
Apr 25, 2023
Merged

feat: async data loader #6137

merged 43 commits into from
Apr 25, 2023

Conversation

chenjun1011
Copy link
Collaborator

@chenjun1011 chenjun1011 commented Apr 6, 2023

feat: #6124

return routeData;
};

if (loaderConfig?.[1]?.defer) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 1 是干啥的😂

Base automatically changed from refactor/react-router to release/next April 13, 2023 04:01
@chenjun1011 chenjun1011 changed the title [WIP]feat: async data loader feat: async data loader Apr 18, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 18, 2023

Codecov Report

Patch coverage: 62.00% and project coverage change: +0.03 🎉

Comparison is base (71bd792) 81.78% compared to head (3b7fcb9) 81.82%.

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     
Impacted Files Coverage Δ
packages/runtime/src/dataLoader.ts 45.76% <25.64%> (+2.11%) ⬆️
packages/runtime/src/routes.tsx 81.01% <73.73%> (-10.10%) ⬇️
packages/runtime/src/appData.ts 94.11% <81.81%> (+1.26%) ⬆️
packages/ice/src/constant.ts 100.00% <100.00%> (ø)

... 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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@chenjun1011 chenjun1011 added the need review Need Review label Apr 18, 2023
}

const loader = appExport?.dataLoader;
const appDataLoaderConfig = appExport?.dataLoader;
Copy link
Collaborator

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';
Copy link
Collaborator

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 {
Copy link
Collaborator

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}]

感觉还是对象会比较清晰

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已调整

@luhc228 luhc228 mentioned this pull request Apr 24, 2023
18 tasks
dataLoader: async () => ({ type: 'getData' }),
serverDataLoader: async () => ({ type: 'getServerData' }),
staticDataLoader: async () => ({ type: 'getStaticData' }),
dataLoader: { loader: async () => ({ type: 'getData' }) },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在的变化是不是有 breakchange,如果不通过 defineDataLoader 的形式指定的话

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以通过兼容 function 或 数组的场景来实现

@ClarkXia ClarkXia merged commit f56497f into release/next Apr 25, 2023
@ClarkXia ClarkXia deleted the feat/async-data-loader branch April 25, 2023 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need review Need Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants