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
impl Worker for ModalCloser
§type Input = ModalCloseMsg
type Input = ModalCloseMsg
Incoming message type.
§type Output = ModalCloseMsg
type Output = ModalCloseMsg
Outgoing message type.
§type Reach = Public<ModalCloser>
type Reach = Public<ModalCloser>
Reach capability of the worker.
source§fn handle_input(&mut self, msg: Self::Input, _: HandlerId)
fn handle_input(&mut self, msg: Self::Input, _: HandlerId)
This method called on every incoming message.
source§fn disconnected(&mut self, id: HandlerId)
fn disconnected(&mut self, id: HandlerId)
This method called on when a new bridge destroyed.
§fn name_of_resource() -> &'static str
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
fn resource_path_is_relative() -> bool
Indicates whether the name of the resource is relative. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for ModalCloser
impl !Send for ModalCloser
impl !Sync for ModalCloser
impl Unpin for ModalCloser
impl !UnwindSafe for ModalCloser
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
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>,
impl<T> Bridged for Twhere T: Worker, <T as Worker>::Reach: Discoverer<Worker = T>,
§impl<T> Dispatched for Twhere
T: Worker,
<T as Worker>::Reach: Discoverer<Worker = T> + Dispatchable,
impl<T> Dispatched for Twhere T: Worker, <T as Worker>::Reach: Discoverer<Worker = T> + Dispatchable,
§fn dispatcher() -> Dispatcher<T>
fn dispatcher() -> Dispatcher<T>
Creates a dispatcher to the worker that will not send messages back. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self
to a value of a Properties
struct.source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self
to a value of a Properties
struct.