pub struct AppHandle<COMP>where
COMP: Component,{ /* private fields */ }Expand description
An instance of an application.
Implementations
Methods from Deref<Target = Scope<COMP>>
sourcepub fn get_parent(&self) -> Option<&AnyScope>
pub fn get_parent(&self) -> Option<&AnyScope>
Returns the parent scope
sourcepub fn get_component(&self) -> Option<impl Deref<Target = COMP>>
pub fn get_component(&self) -> Option<impl Deref<Target = COMP>>
Returns the linked component if available
sourcepub fn send_message<T>(&self, msg: T)where
T: Into<<COMP as Component>::Message>,
pub fn send_message<T>(&self, msg: T)where
T: Into<<COMP as Component>::Message>,
Send a message to the component.
Please be aware that currently this method synchronously schedules a call to the Component interface.
sourcepub fn send_message_batch(
&self,
messages: Vec<<COMP as Component>::Message, Global>
)
pub fn send_message_batch(
&self,
messages: Vec<<COMP as Component>::Message, Global>
)
Send a batch of messages to the component.
This is useful for reducing re-renders of the components because the messages are handled together and the view function is called only once if needed.
Please be aware that currently this method synchronously schedules calls to the Component interface.
sourcepub fn callback<F, IN, M>(&self, function: F) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
F: 'static + Fn(IN) -> M,
pub fn callback<F, IN, M>(&self, function: F) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
F: 'static + Fn(IN) -> M,
Creates a Callback which will send a message to the linked
component’s update method when invoked.
Please be aware that currently the result of this callback synchronously schedules a call to the Component interface.
sourcepub fn callback_with_passive<F, IN, M>(
&self,
passive: impl Into<Option<bool>>,
function: F
) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
F: 'static + Fn(IN) -> M,
pub fn callback_with_passive<F, IN, M>(
&self,
passive: impl Into<Option<bool>>,
function: F
) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
F: 'static + Fn(IN) -> M,
Creates a Callback which will send a message to the linked
component’s update method when invoked.
Setting passive to Some explicitly makes the event listener passive or not.
Yew sets sane defaults depending on the type of the listener.
See
addEventListener.
Please be aware that currently the result of this callback synchronously schedules a call to the Component interface.
sourcepub fn callback_once<F, IN, M>(&self, function: F) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
F: 'static + FnOnce(IN) -> M,
pub fn callback_once<F, IN, M>(&self, function: F) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
F: 'static + FnOnce(IN) -> M,
Creates a Callback from an FnOnce which will send a message
to the linked component’s update method when invoked.
Please be aware that currently the result of this callback will synchronously schedule calls to the Component interface.
sourcepub fn batch_callback<F, IN, OUT>(&self, function: F) -> Callback<IN>where
F: 'static + Fn(IN) -> OUT,
OUT: SendAsMessage<COMP>,
pub fn batch_callback<F, IN, OUT>(&self, function: F) -> Callback<IN>where
F: 'static + Fn(IN) -> OUT,
OUT: SendAsMessage<COMP>,
Creates a Callback which will send a batch of messages back
to the linked component’s update method when invoked.
The callback function’s return type is generic to allow for dealing with both
Option and Vec nicely. Option can be used when dealing with a callback that
might not need to send an update.
link.batch_callback(|_| vec![Msg::A, Msg::B]);
link.batch_callback(|_| Some(Msg::A));Please be aware that currently the results of these callbacks will synchronously schedule calls to the Component interface.
sourcepub fn batch_callback_once<F, IN, OUT>(&self, function: F) -> Callback<IN>where
F: 'static + FnOnce(IN) -> OUT,
OUT: SendAsMessage<COMP>,
pub fn batch_callback_once<F, IN, OUT>(&self, function: F) -> Callback<IN>where
F: 'static + FnOnce(IN) -> OUT,
OUT: SendAsMessage<COMP>,
Creates a Callback from an FnOnce which will send a batch of messages back
to the linked component’s update method when invoked.
The callback function’s return type is generic to allow for dealing with both
Option and Vec nicely. Option can be used when dealing with a callback that
might not need to send an update.
link.batch_callback_once(|_| vec![Msg::A, Msg::B]);
link.batch_callback_once(|_| Some(Msg::A));Please be aware that currently the results of these callbacks will synchronously schedule calls to the Component interface.
sourcepub fn callback_future<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
FU: 'static + Future<Output = M>,
FN: 'static + Fn(IN) -> FU,
pub fn callback_future<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
FU: 'static + Future<Output = M>,
FN: 'static + Fn(IN) -> FU,
sourcepub fn callback_future_once<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
FU: 'static + Future<Output = M>,
FN: 'static + FnOnce(IN) -> FU,
pub fn callback_future_once<FN, FU, IN, M>(&self, function: FN) -> Callback<IN>where
M: Into<<COMP as Component>::Message>,
FU: 'static + Future<Output = M>,
FN: 'static + FnOnce(IN) -> FU,
sourcepub fn send_future<F, M>(&self, future: F)where
M: Into<<COMP as Component>::Message>,
F: 'static + Future<Output = M>,
pub fn send_future<F, M>(&self, future: F)where
M: Into<<COMP as Component>::Message>,
F: 'static + Future<Output = M>,
This method processes a Future that returns a message and sends it back to the component’s loop.
Panics
If the future panics, then the promise will not resolve, and will leak.
Trait Implementations
Auto Trait Implementations
impl<COMP> !RefUnwindSafe for AppHandle<COMP>
impl<COMP> !Send for AppHandle<COMP>
impl<COMP> !Sync for AppHandle<COMP>
impl<COMP> Unpin for AppHandle<COMP>
impl<COMP> !UnwindSafe for AppHandle<COMP>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
sourcefn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.sourceimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
sourcefn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.