🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@Flo0806
Copy link
Collaborator

@Flo0806 Flo0806 commented Sep 13, 2025

🔗 Linked issue

Resolves #32956.
Related: #32959 (initial deprecation doc PR), #32960 (v5 cleanup discussion).
Resolves: #33571
closes #33594


📚 Description

Summary
Document pending on useAsyncData as an alias of status === 'pending', per the maintainers’ direction to keep and document it.

What changed

  • Added pending to the refs note (Usage section), alongside data, status, and error.
  • Added a new Return Value entry for pending (Ref<boolean>) with an explicit note: it’s effectively computed(() => status.value === 'pending').
  • Updated the Shared State intro sentence to mention that pending is shared as it derives from status.
  • Extended the AsyncData type shape with:
    /** Alias of computed(() => status.value === 'pending') */
    pending: Ref<boolean>

Why
pending exists in the interface and is widely used, but it wasn’t visible in the docs. This PR closes that documentation gap and aligns the page with current behavior (keep & document, not deprecate). It should reduce confusion and improve DX.

Notes

  • Docs-only change; no runtime behavior or API surface changed.

Suggested PR title (Conventional Commits)
docs(asyncData): document 'pending' as alias of status === 'pending'

@Flo0806 Flo0806 requested a review from danielroe as a code owner September 13, 2025 08:49
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@Flo0806 Flo0806 changed the title docs(asyncData): document as alias of status === 'pending' docs: document 'pending' as alias of status === 'pending' Sep 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new pending member to the useAsyncData return value and public API: pending is a Ref<boolean> that aliases computed(() => status.value === 'pending'). Documentation examples, the Return Values section, and notes on Shared State and Option Consistency were updated to include and describe pending. The public AsyncData<DataT, ErrorT> type/interface now declares pending: Ref<boolean> with a JSDoc comment documenting it as the computed alias.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Areas to check during review:

  • docs/3.api/2.composables/use-async-data.md — examples, return values, and notes for accuracy and consistency
  • Public type/interface declaration for AsyncData<DataT, ErrorT> — ensure pending: Ref<boolean> and JSDoc are correctly typed and presented
  • Example code snippets that destructure pending alongside data, status, error, refresh, and clear for correctness and formatting

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "docs: document 'pending' as alias of status === 'pending'" is fully aligned with the changeset. The title clearly and concisely conveys the primary change—adding documentation for the previously undocumented pending field on useAsyncData and describing it as an alias of status === 'pending'. The title follows Conventional Commits conventions and is specific enough that a teammate scanning the history would immediately understand the intent of this documentation update.
Linked Issues Check ✅ Passed The pull request successfully addresses both linked issues. For issue #32956, which requested surfacing the undocumented pending field in the AsyncData documentation, the PR adds pending to the refs note, creates a dedicated Return Value entry for pending, and extends the AsyncData type shape with proper documentation. For issue #33571, which identified the missing return value documentation for the pending field on useAsyncData and useFetch, the PR directly fulfils this by documenting pending as a Ref<boolean> with an explicit alias notation. All coding-related requirements from both issues are met.
Out of Scope Changes Check ✅ Passed All changes in this pull request are directly in scope and aligned with the stated objectives from the linked issues. The modifications are limited to documentation updates in the use-async-data.md file, specifically adding documentation for the pending field as an alias of status === 'pending'. There are no runtime code changes, no API surface modifications, and no unrelated documentation updates. Every change directly supports the objectives outlined in issues #32956 and #33571.
Description Check ✅ Passed The pull request description is directly and clearly related to the changeset. The author describes the specific documentation changes made: adding pending to the refs note in the Usage section, adding a new Return Value entry for pending, updating the Shared State intro, and extending the AsyncData type shape. These descriptions align precisely with the raw summary which confirms documentation notes were updated to include pending, the Return values section was expanded, the Shared state explanation was extended, and the public API surface was updated with the pending: Ref<boolean> member. The description also provides helpful context about the purpose (documenting pending as an alias of status === 'pending' per maintainers' direction) and references specific related issues, demonstrating clear intent and relevance to the changeset.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b025cb5 and b7a0fd2.

📒 Files selected for processing (1)
  • docs/3.api/2.composables/use-async-data.md (5 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
docs/3.api/2.composables/use-async-data.md (4)

21-25: Show pending in the destructure, not only as a comment.

Make pending discoverable by including it in the example destructure.

-const { data, status /* pending (alias) */, error, refresh, clear } = await useAsyncData(
+const { data, status, pending, error, refresh, clear } = await useAsyncData(

33-34: Clarify ref unwrapping in templates.

Small wording tweak to mention auto-unwrapping in templates.

-`data`, `status`, `pending` and `error` are Vue refs and they should be accessed with `.value` when used within the `<script setup>`, while `refresh`/`execute` and `clear` are plain functions.
+`data`, `status`, `pending` and `error` are Vue refs and should be accessed with `.value` in `<script setup>` (auto-unwrapped in templates). `refresh`/`execute` and `clear` are plain functions.

118-119: Minor phrasing polish for readability.

Tighten the parenthetical about pending.

-When using the same key for multiple `useAsyncData` calls, they will share the same `data`, `error` and `status` refs (and `pending`, as it derives from `status`). This ensures consistency across components but requires option consistency.
+When using the same key for multiple `useAsyncData` calls, they share the same `data`, `error` and `status` refs (and `pending`, which derives from `status`). This ensures consistency across components but requires option consistency.

209-211: Confirmed: AsyncData.pending present in source; align docs generics

  • packages/nuxt/src/app/composables/asyncData.ts — contains pending: Ref<boolean> (≈ line 118) and export type AsyncData<Data, Error> = _AsyncData<Data, Error> & Promise<_AsyncData<Data, Error>> (≈ line 126).
  • Docs use DataE / ErrorT — update docs to Data / Error or rename the source generics for consistency.
  • No JSDoc alias computed(() => status.value === 'pending') found in the source; add that comment to the implementation or remove it from the docs to avoid drift.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 412786a and 827568a.

📒 Files selected for processing (1)
  • docs/3.api/2.composables/use-async-data.md (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-10T14:42:56.613Z
Learnt from: Tofandel
PR: nuxt/nuxt#33192
File: test/nuxt/use-async-data.test.ts:366-373
Timestamp: 2025-09-10T14:42:56.613Z
Learning: In the Nuxt useAsyncData test "should watch params deeply in a non synchronous way", the foo watcher intentionally updates both params.foo and params.locale using locale.value, simulating a scenario where one watcher consolidates multiple reactive values into a shared params object for testing debounced/non-synchronous behavior.

Applied to files:

  • docs/3.api/2.composables/use-async-data.md
🔇 Additional comments (1)
docs/3.api/2.composables/use-async-data.md (1)

161-163: LGTM: pending return value documented clearly.

Accurately describes pending as an alias of status === 'pending'.

@Flo0806 Flo0806 force-pushed the docs/asyncdata-pending branch from 827568a to 77d24a8 Compare September 13, 2025 19:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
docs/3.api/2.composables/use-async-data.md (3)

21-21: Show pending in the destructuring for clarity

Readers may miss that pending is available if it’s only mentioned in a comment. Explicitly destructure it.

-const { data, status /* pending (alias) */, error, refresh, clear } = await useAsyncData(
+const { data, status, pending, error, refresh, clear } = await useAsyncData(

33-33: Tighten copy; clarify template access

Minor wording polish and note that .value isn’t needed in templates.

-`data`, `status`, `pending` and `error` are Vue refs and they should be accessed with `.value` when used within the `<script setup>`, while `refresh`/`execute` and `clear` are plain functions.
+`data`, `status`, `pending` and `error` are Vue refs; in `<script setup>` access them with `.value` (in templates you can omit `.value`). `refresh`/`execute` and `clear` are plain functions.

161-162: Make the alias phrasing more direct

Small style tweak.

-- `pending`: a `Ref<boolean>` that is `true` while the request is in progress.
-  This is effectively an alias of `computed(() => status.value === 'pending')`.
+- `pending`: a `Ref<boolean>` that is `true` while the request is in progress. Alias of `computed(() => status.value === 'pending')`.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 827568a and 77d24a8.

📒 Files selected for processing (1)
  • docs/3.api/2.composables/use-async-data.md (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-10T14:42:56.613Z
Learnt from: Tofandel
PR: nuxt/nuxt#33192
File: test/nuxt/use-async-data.test.ts:366-373
Timestamp: 2025-09-10T14:42:56.613Z
Learning: In the Nuxt useAsyncData test "should watch params deeply in a non synchronous way", the foo watcher intentionally updates both params.foo and params.locale using locale.value, simulating a scenario where one watcher consolidates multiple reactive values into a shared params object for testing debounced/non-synchronous behavior.

Applied to files:

  • docs/3.api/2.composables/use-async-data.md
🔇 Additional comments (2)
docs/3.api/2.composables/use-async-data.md (2)

118-118: Good clarification that pending is shared via status

This makes the sharing model explicit and avoids confusion.


209-210: Docs vs code parity: confirm AsyncData already exposes pending

The PR description says docs‑only; ensure the runtime/types already include pending so the docs don’t get ahead. The AI summary claims a code change adding pending to the public type, which isn’t present in this PR.

Run to verify the type in the repo:

#!/bin/bash
# Find AsyncData definitions and check for `pending: Ref<boolean>`
rg -nP -C3 '(type|interface)\s+AsyncData\b' -g '!**/dist/**' -g '!**/node_modules/**'
rg -nP -C2 '\bpending:\s*Ref<\s*boolean\s*>' -g '!**/dist/**' -g '!**/node_modules/**'

@Flo0806 Flo0806 force-pushed the docs/asyncdata-pending branch 2 times, most recently from 3f68535 to 82ec0dd Compare September 24, 2025 09:59
@Flo0806 Flo0806 force-pushed the docs/asyncdata-pending branch from 82ec0dd to 0daf23f Compare September 25, 2025 06:46
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

Thank you! and apologies for the delay on this one.

@danielroe danielroe merged commit 99be353 into nuxt:main Oct 28, 2025
6 of 8 checks passed
@github-actions github-actions bot mentioned this pull request Oct 28, 2025
danielroe pushed a commit that referenced this pull request Nov 6, 2025
Co-authored-by: PaulyBearCoding <PaulyBearCoding@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[doc] Missing return value for useAsyncData and useFetch The pending field for AsyncData is undocumented

2 participants