Explain Action pattern a bit in The Pocket Guide
This commit is contained in:
parent
9e5afc54ce
commit
1ada297b08
1 changed files with 10 additions and 2 deletions
12
src/lib.rs
12
src/lib.rs
|
|
@ -456,8 +456,16 @@
|
|||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! Functor methods like [`Task::map`], [`Element::map`], and [`Subscription::map`] make this
|
||||
//! approach seamless.
|
||||
//! The `update` method of a screen can return an `Action` enum that can be leveraged by the parent to
|
||||
//! execute a task or transition to a completely different screen altogether. The variants of `Action` can
|
||||
//! have associated data. For instance, in the example above, the `Conversation` screen is created when
|
||||
//! `Contacts::update` returns an `Action::Chat` with the selected contact.
|
||||
//!
|
||||
//! Effectively, this approach lets you "tell a story" to connect different screens together in a type safe
|
||||
//! way.
|
||||
//!
|
||||
//! Furthermore, functor methods like [`Task::map`], [`Element::map`], and [`Subscription::map`] make composition
|
||||
//! seamless.
|
||||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/bdf0430880f5c29443f5f0a0ae4895866dfef4c6/docs/logo.svg"
|
||||
)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue