Skip to content

Commit 3b4fa88

Browse files
authored
add ability to update app props (#2951)
1 parent b649e9d commit 3b4fa88

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/yew/src/app_handle.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ where
4646
app
4747
}
4848

49+
/// Update the properties of the app's root component.
50+
///
51+
/// This can be an alternative to sending and handling messages. The existing component will be
52+
/// reused and have its properties updates. This will presumably trigger a re-render, refer to
53+
/// the [`changed`] lifecycle for details.
54+
///
55+
/// [`changed`]: crate::Component::changed
56+
#[tracing::instrument(
57+
level = tracing::Level::DEBUG,
58+
skip_all,
59+
)]
60+
pub fn update(&mut self, new_props: COMP::Properties) {
61+
self.scope.reuse(Rc::new(new_props), NodeRef::default())
62+
}
63+
4964
/// Schedule the app for destruction
5065
#[tracing::instrument(
5166
level = tracing::Level::DEBUG,

0 commit comments

Comments
 (0)