simplify use_dependencies docs

This commit is contained in:
Evan Almloff committed 2024-03-13 10:03:00 -05:00
1 parent 0951a389f7
commit 3866aa2977
3 files changed
+7 -26

No files matched your search

+4 -14
View File
@@ -65,23 +65,13 @@ impl Effect {
/// ///
/// #[component] /// #[component]
/// fn Comp(delay: u32) -> Element { /// fn Comp(delay: u32) -> Element {
/// // Because the resource subscribes to `delay` by adding it as a dependency, the effect's closure will rerun every time `delay` changes. /// // Because the effect subscribes to `delay` by adding it as a dependency, the effect's closure will rerun every time `delay` changes.
/// let current_weather = use_resource(move || async move { /// use_effect(move || {
/// sleep(delay).await; /// println!("It is safe to manually manipulate the dom here");
/// "Sunny"
/// }) /// })
/// .use_dependencies((&delay,)); /// .use_dependencies((&delay,));
/// ///
/// rsx! { /// todo!()
/// // the value of the resource can be polled to
/// // conditionally render elements based off if it's future
/// // finished (Some(Ok(_)), errored Some(Err(_)),
/// // or is still running (None)
/// match &*current_weather.read_unchecked() {
/// Some(weather) => rsx! { "{weather}" },
/// None => rsx! { p { "Loading..." } }
/// }
/// }
/// } /// }
/// ``` /// ```
pub fn use_dependencies(mut self, dependency: impl Dependency) -> Self { pub fn use_dependencies(mut self, dependency: impl Dependency) -> Self {
+1 -10
View File
@@ -144,16 +144,7 @@ impl<T> Resource<T> {
/// }) /// })
/// .use_dependencies((&delay,)); /// .use_dependencies((&delay,));
/// ///
/// rsx! { /// todo!()
/// // the value of the resource can be polled to
/// // conditionally render elements based off if it's future
/// // finished (Some(Ok(_)), errored Some(Err(_)),
/// // or is still running (None)
/// match &*current_weather.read_unchecked() {
/// Some(weather) => rsx! { "{weather}" },
/// None => rsx! { p { "Loading..." } }
/// }
/// }
/// } /// }
/// ``` /// ```
pub fn use_dependencies(mut self, dependency: impl Dependency) -> Self { pub fn use_dependencies(mut self, dependency: impl Dependency) -> Self {
+2 -2
View File
@@ -166,8 +166,8 @@ impl<T: 'static> Memo<T> {
/// ///
/// #[component] /// #[component]
/// fn Comp(count: u32) -> Element { /// fn Comp(count: u32) -> Element {
/// // Because the resource subscribes to `delay` by adding it as a dependency, the memo will rerun every time `count` changes. /// // Because the memo subscribes to `count` by adding it as a dependency, the memo will rerun every time `count` changes.
/// let new_count = use_memo(move || async move { /// let new_count = use_memo(move || {
/// count + 1 /// count + 1
/// }) /// })
/// .use_dependencies((&count,)); /// .use_dependencies((&count,));