[−][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 you must always wrap the callback in an Option
, because the properties
object is constructed using Default::default()
before filling in the property values,
and it needs a safe and constructable default value for the callback. More crucially,
for this reason the machinery which figures out the callback's type signature is
implemented for Option<Callback<_>>
but not for plain Callback<_>
.
struct MyComponentProperties { on_message: Option<Callback<String>>, }
This is how you might provide a callback property to the above:
<@MyComponent on_message=|string| ParentMessage::StringReceived(string) />
Methods
impl<A: Debug> Callback<A>
[src]
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, 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>,