-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Conversation
packages/core/src/global_context.rs
Outdated
/// | ||
/// 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) |
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.
Thanks this is more clear. I think on-op should be no-op
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.
Fixed.
packages/core/src/global_context.rs
Outdated
@@ -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. |
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.
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
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.
I misread the API. I think the new test is fixed now.
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.