Struct ybc::ModalCloser

source ·
pub struct ModalCloser { /* private fields */ }
Expand description

An agent used for being able to close Modal & ModalCard instances by ID.

If custom modal closing functionality is need for your modal instance, the following pattern is recommended.

First, in your component which is using this modal, configure a ModalCloser dispatcher.

use yew::agent::Dispatcher;
use yew::prelude::*;
// .. snip ..
fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
    let bridge = ModalCloser::dispatcher();
    Self { link, props, bridge }
}

Next, in your component’s view method, setup a callback to handle your component’s close event. ```rust let closer = self.link.callback(|_| ModalCloseMsg(“modal-0”.into())); // … snip … <ModalCard id=“modal-0” // … snip … footer=html!{ } />


Finally, in your component's `update` method, send the `ModalCloseMsg` over to the agent which
will forward the message to the modal to cause it to close.
```rust
fn update(&mut self, msg: Self::Message) -> ShouldRender {
    self.bridge.send(msg);
    true
}

This pattern allows you to communicate with a modal by its given ID, allowing you to close the modal from anywhere in your application.

Trait Implementations§

source§

impl Worker for ModalCloser

§

type Input = ModalCloseMsg

Incoming message type.
§

type Message = ()

Type of an input message.
§

type Output = ModalCloseMsg

Outgoing message type.
§

type Reach = Public<ModalCloser>

Reach capability of the worker.
source§

fn create(link: WorkerLink<Self>) -> Self

Creates an instance of an worker.
source§

fn update(&mut self, _: Self::Message)

This method called on every update message.
source§

fn handle_input(&mut self, msg: Self::Input, _: HandlerId)

This method called on every incoming message.
source§

fn connected(&mut self, id: HandlerId)

This method called on when a new bridge created.
source§

fn disconnected(&mut self, id: HandlerId)

This method called on when a new bridge destroyed.
§

fn destroy(&mut self)

This method called when the worker is destroyed.
§

fn name_of_resource() -> &'static str

Represents the name of loading resource for remote workers which have to live in a separate files.
§

fn resource_path_is_relative() -> bool

Indicates whether the name of the resource is relative. Read more
§

fn is_module() -> bool

Signifies if resource is a module. This has pending browser support.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Bridged for Twhere T: Worker, <T as Worker>::Reach: Discoverer<Worker = T>,

§

fn bridge( callback: Rc<dyn Fn(<T as Worker>::Output) + 'static> ) -> Box<dyn Bridge<T> + 'static, Global>

Creates a messaging bridge between a worker and the component.
§

impl<T> Dispatched for Twhere T: Worker, <T as Worker>::Reach: Discoverer<Worker = T> + Dispatchable,

§

fn dispatcher() -> Dispatcher<T>

Creates a dispatcher to the worker that will not send messages back. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoPropValue<Option<T>> for T

source§

fn into_prop_value(self) -> Option<T>

Convert self to a value of a Properties struct.
source§

impl<T> IntoPropValue<T> for T

source§

fn into_prop_value(self) -> T

Convert self to a value of a Properties struct.
§

impl<W> PublicWorker for Wwhere W: Worker<Reach = Public<W>>, <W as Worker>::Input: Serialize + for<'de> Deserialize<'de>, <W as Worker>::Output: Serialize + for<'de> Deserialize<'de>,

§

fn register()

Executes an worker in the current environment. Uses in main function of a worker.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> Any for Twhere T: Any,

source§

impl<T> HasAllProps<(), T> for T