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: support API useDocumentData #6408

Merged
merged 6 commits into from
Aug 31, 2023
Merged

feat: support API useDocumentData #6408

merged 6 commits into from
Aug 31, 2023

Conversation

ClarkXia
Copy link
Collaborator

@ClarkXia ClarkXia commented Jul 24, 2023

Usage

Step 1: export dataLoader in src/document.tsx

// 这里参考 data-loader 的定义
export const dataLoader = defineDataLoader(() => {/* ... */});

Step2: use API unstable_useDocumentData imported from ice

import { unstable_useDocumentData } from 'ice';

临时解决方案,需要 document 计划改造成 RSC 方式执行

@wssgcg1213
Copy link
Collaborator

  • documentData 的获取逻辑在 app 中定义, 这个行为我认为不太符合预期
  • 从语义上来说, document 的数据应当在 document 中定义, 使用 defineDataLoader 的 Interface
  • 实质上这种行为永远是 async: false, 即在渲染 document 之前是阻塞式执行, 此类需求更合适的是通过 RSC 来实现

@wssgcg1213 wssgcg1213 changed the base branch from master to release/next August 24, 2023 03:09
@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2023

Codecov Report

Patch coverage: 52.27% and project coverage change: +0.96% 🎉

Comparison is base (47ba84d) 79.23% compared to head (26d70d9) 80.20%.
Report is 6 commits behind head on release/next.

Additional details and impacted files
@@               Coverage Diff                @@
##           release/next    #6408      +/-   ##
================================================
+ Coverage         79.23%   80.20%   +0.96%     
================================================
  Files               251      251              
  Lines             21982    22030      +48     
  Branches           2683     2717      +34     
================================================
+ Hits              17418    17669     +251     
+ Misses             4520     4317     -203     
  Partials             44       44              
Files Changed Coverage Δ
packages/runtime/src/index.ts 83.92% <22.22%> (-16.08%) ⬇️
packages/runtime/src/runServerApp.tsx 75.65% <58.82%> (-1.12%) ⬇️
packages/ice/src/constant.ts 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ClarkXia ClarkXia changed the title [WIP] feat: support API useDocumentData feat: support API useDocumentData Aug 29, 2023
@ClarkXia ClarkXia added the need review Need Review label Aug 29, 2023
@ClarkXia ClarkXia requested a review from wssgcg1213 August 29, 2023 07:10
@wssgcg1213 wssgcg1213 removed their request for review August 29, 2023 07:29
chenjun1011
chenjun1011 previously approved these changes Aug 29, 2023
@ClarkXia ClarkXia requested a review from chenjun1011 August 30, 2023 10:09
@ClarkXia ClarkXia merged commit 69e6863 into release/next Aug 31, 2023
6 checks passed
@ClarkXia ClarkXia deleted the feat/documentdata branch August 31, 2023 02:12
HomyeeKing pushed a commit to HomyeeKing/ice that referenced this pull request Sep 11, 2023
* feat: support API useDocumentData

* refactor: make document data unstable

* refactor: document data loader

* chore: lint

* chore: lint

* chore: lint

---------

Co-authored-by: ZeroLing <zhuoling.lcl@alibaba-inc.com>
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.

5 participants