[−][src]Struct vgtk::Callback
A callback property for sub-Component
s.
When a subcomponent needs to communicate with its parent, you can use a Callback
to simulate a signal handler.
This is how you would declare a callback property that receives a String
when
something happens inside the subcomponent. The property value should be a closure
which receives the String
and returns a message for the parent component, of the
parent component's Component::Message
type. The framework will automatically take
care of figuring out the callback's type signature when you mount the subcomponent.
Note that the Default
implementation for Callback
constructs an empty callback,
which does nothing and allocates nothing. This is the desired behaviour when using a callback
as a Component
property: if the user doesn't specify a callback explicitly, there
shouldn't be a callback.
struct MyComponentProperties { on_message: Callback<String>, }
This is how you might provide a callback property to the above:
<@MyComponent on_message=|string| ParentMessage::StringReceived(string) />
Methods
impl<A> Callback<A>
[src]
pub fn send(&self, value: A)
[src]
Send a value to the callback.
If the callback is empty, this has no effect.
pub fn is_empty(&self) -> bool
[src]
Test whether a callback is empty.
Trait Implementations
impl<A> Clone for Callback<A>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<A> Debug for Callback<A>
[src]
impl<A> Default for Callback<A>
[src]
impl<A, F: Fn(A) + 'static> From<F> for Callback<A>
[src]
impl<A> PartialEq<Callback<A>> for Callback<A>
[src]
Auto Trait Implementations
impl<A> !RefUnwindSafe for Callback<A>
impl<A> !Send for Callback<A>
impl<A> !Sync for Callback<A>
impl<A> Unpin for Callback<A>
impl<A> !UnwindSafe for Callback<A>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,