Struct yew::AppHandle

source ·
pub struct AppHandle<COMP: BaseComponent> { /* private fields */ }
Available on crate feature csr only.
Expand description

An instance of an application.

Implementations§

Update the properties of the app’s root component.

This can be an alternative to sending and handling messages. The existing component will be reused and have its properties updates. This will presumably trigger a re-render, refer to the changed lifecycle for details.

Schedule the app for destruction

Methods from Deref<Target = Scope<COMP>>§

Returns the parent scope

Creates a Callback which will send a message to the linked component’s update method when invoked.

If your callback function returns a Future, use callback_future instead.

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));

Accesses a value provided by a parent ContextProvider component of the same type.

This method asynchronously awaits a Future that returns a message and sends it to the linked component.

Panics

If the future panics, then the promise will not resolve, and will leak.

This method creates a Callback which, when emitted, asynchronously awaits the message returned from the passed function before sending it to the linked component.

Panics

If the future panics, then the promise will not resolve, and will leak.

Asynchronously send a batch of messages to a component. This asynchronously awaits the passed Future, before sending the message batch to the linked component.

Panics

If the future panics, then the promise will not resolve, and will leak.

This method asynchronously awaits a [Stream] that returns a series of messages and sends them to the linked component.

Panics

If the stream panics, then the promise will not resolve, and will leak.

Note

This method will not notify the component when the stream has been fully exhausted. If you want this feature, you can add an EOF message variant for your component and use [StreamExt::chain] and stream::once to chain an EOF message to the original stream. If your stream is produced by another crate, you can use [StreamExt::map] to transform the stream’s item type to the component message type.

Returns the linked component if available

Send a message to the component.

Send a batch of messages to the component.

This is slightly more efficient than calling send_message in a loop.

Trait Implementations§

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more