[−][src]Struct ybc::ModalCloser
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.
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.
let closer = self.link.callback(|_| ModalCloseMsg("modal-0".into())); // ... snip ... <ModalCard id="modal-0" // ... snip ... footer=html!{ <Button onclick=Some(closer)>{"Close"}</Button> } />
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.
fn update(&mut self, msg: Self::Message) -> ShouldRender { self.bridge.send(msg); true }
This pattern allows you to communicate with a modal by the ID which you have to it, allowing you to close the modal from anywhere in your application.
Trait Implementations
impl Agent for ModalCloser
[src]
type Reach = Context<Self>
Reach capability of the agent.
type Message = ()
Type of an input message.
type Input = ModalCloseMsg
Incoming message type.
type Output = ModalCloseMsg
Outgoing message type.
fn create(link: AgentLink<Self>) -> Self
[src]
fn update(&mut self, _: Self::Message)
[src]
fn handle_input(&mut self, msg: Self::Input, _: HandlerId)
[src]
fn connected(&mut self, id: HandlerId)
[src]
fn disconnected(&mut self, id: HandlerId)
[src]
fn destroy(&mut self)
[src]
fn name_of_resource() -> &'static str
[src]
fn is_module() -> bool
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Bridged for T where
T: Agent,
<T as Agent>::Reach: Discoverer,
<<T as Agent>::Reach as Discoverer>::Agent == T,
[src]
T: Agent,
<T as Agent>::Reach: Discoverer,
<<T as Agent>::Reach as Discoverer>::Agent == T,
impl<T> Dispatched for T where
T: Agent,
<T as Agent>::Reach: Discoverer,
<T as Agent>::Reach: Dispatchable,
<<T as Agent>::Reach as Discoverer>::Agent == T,
[src]
T: Agent,
<T as Agent>::Reach: Discoverer,
<T as Agent>::Reach: Dispatchable,
<<T as Agent>::Reach as Discoverer>::Agent == T,
fn dispatcher() -> Dispatcher<T>
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> NeqAssign<U> for T where
T: BorrowMut<U>,
U: PartialEq<U>,
[src]
T: BorrowMut<U>,
U: PartialEq<U>,
fn neq_assign(&mut self, new: U) -> bool
[src]
impl<T, U> NeqAssignBy<U> for T where
T: BorrowMut<U>,
[src]
T: BorrowMut<U>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,