Skip to content

Clarify schedule_update docs #4127

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Craig-Macomber
Copy link

@Craig-Macomber Craig-Macomber commented May 16, 2025

As noted in #4114, the current documentation of schedule_update can be a bit confusing.

This attempts to clarify its behavior and direct readers to the well documented ReactiveContext instead when appropriate.

@Craig-Macomber Craig-Macomber requested a review from a team as a code owner May 16, 2025 06:27
///
/// Note: Unlike [`needs_update`], the function returned by this method will work outside of the dioxus runtime.
///
/// Note: The function returned by this method will schedule an update for the current component even if it has already updated between when `schedule_update` was called and when the returned function is called.
/// If the desired behavior is to invalidate the current rendering of the current component (and on-op if already invalidated)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks this is more clear. I think on-op should be no-op

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

@@ -349,6 +353,9 @@ pub fn schedule_update() -> Arc<dyn Fn() + Send + Sync> {
/// A component's [`ScopeId`] can be obtained from the [`current_scope_id`] method.
///
/// Note: Unlike [`needs_update`], the function returned by this method will work outside of the dioxus runtime.
///
/// Note: The function returned by this method will schedule an update for the component even if it has already updated between when `schedule_update` was called and when the returned function is called.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this comment is relevant to schedule_update_any since it doesn't capture anything about the component. We could still point to ReactiveContext as a way to update any reactive scope, not just components, or remove this comment

Copy link
Author

Choose a reason for hiding this comment

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

I misread the API. I think the new test is fixed now.

@ealmloff ealmloff added the documentation Improvements or additions to documentation label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants