Skip to content

Commit

Permalink
Document how the state of a Component can be managed
Browse files Browse the repository at this point in the history
  • Loading branch information
dtoniolo authored and hecrj committed Sep 13, 2024
1 parent e9e8e83 commit 2367f78
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions widget/src/lazy/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ use std::rc::Rc;
///
/// Additionally, a [`Component`] is capable of producing a `Message` to notify
/// the parent application of any relevant interactions.
///
/// # State
/// A component can store its state in one of two ways: either as data within the
/// implementor of the trait, or in a type [`State`][Component::State] that is managed
/// by the runtime and provided to the trait methods. These two approaches are not
/// mutually exclusive and have opposite pros and cons.
///
/// For instance, if a piece of state is needed by multiple components that reside
/// in different branches of the tree, then it's more convenient to let a common
/// ancestor store it and pass it down.
///
/// On the other hand, if a piece of state is only needed by the component itself,
/// you can store it as part of its internal [`State`][Component::State].
#[cfg(feature = "lazy")]
#[deprecated(
since = "0.13.0",
Expand Down

0 comments on commit 2367f78

Please sign in to comment.