pub trait Component: Sized + 'static {
type Input: Clone + PartialEq + 'static;
type Message: 'static;
// Required methods
fn create(input: &Self::Input, context: &ComponentContext<Self>) -> Self;
fn view(&self, input: &Self::Input, context: &mut ViewContext<Self>) -> View;
// Provided methods
fn input_changed(
&mut self,
_input: &Self::Input,
_context: &ComponentContext<Self>,
) { ... }
fn update(
&mut self,
_message: Self::Message,
_context: &ComponentContext<Self>,
) { ... }
}Expand description
A stateful unit that turns input and queued messages into a View.
Reactor calls create once, input_changed when unequal
input is applied, and update for accepted queued messages. It then calls
view to publish the current tree and view-time declarations.
Required Associated Types§
Required Methods§
Sourcefn create(input: &Self::Input, context: &ComponentContext<Self>) -> Self
fn create(input: &Self::Input, context: &ComponentContext<Self>) -> Self
Creates component state from its initial input.
Sourcefn view(&self, input: &Self::Input, context: &mut ViewContext<Self>) -> View
fn view(&self, input: &Self::Input, context: &mut ViewContext<Self>) -> View
Builds the current view and records context, effect, and window declarations.
Provided Methods§
Sourcefn input_changed(
&mut self,
_input: &Self::Input,
_context: &ComponentContext<Self>,
)
fn input_changed( &mut self, _input: &Self::Input, _context: &ComponentContext<Self>, )
Responds to a new input value that differs from the current input.
Sourcefn update(&mut self, _message: Self::Message, _context: &ComponentContext<Self>)
fn update(&mut self, _message: Self::Message, _context: &ComponentContext<Self>)
Handles one queued message.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".