[][src]Enum yew::callback::Callback

pub enum Callback<IN> {
    Callback(Rc<dyn Fn(IN)>),
    CallbackOnce(Rc<RefCell<Option<Box<dyn FnOnce(IN)>>>>),
}

Universal callback wrapper.

An `Rc` wrapper is used to make it cloneable.

Variants

Callback(Rc<dyn Fn(IN)>)

A callback which can be called multiple times

CallbackOnce(Rc<RefCell<Option<Box<dyn FnOnce(IN)>>>>)

A callback which can only be called once. The callback will panic if it is called more than once.

Implementations

impl<IN> Callback<IN>[src]

pub fn emit(&self, value: IN)[src]

This method calls the callback's function.

pub fn once<F>(func: F) -> Self where
    F: FnOnce(IN) + 'static, 
[src]

Creates a callback from an FnOnce. The programmer is responsible for ensuring that the callback is only called once. If it is called more than once, the callback will panic.

pub fn noop() -> Self[src]

Creates a "no-op" callback which can be used when it is not suitable to use an Option<Callback>.

impl<IN: 'static> Callback<IN>[src]

pub fn reform<F, T>(&self, func: F) -> Callback<T> where
    F: Fn(T) -> IN + 'static, 
[src]

Changes the input type of the callback to another. Works like the map method but in the opposite direction.

Trait Implementations

impl<IN> Clone for Callback<IN>[src]

impl<IN> Debug for Callback<IN>[src]

impl<IN> Default for Callback<IN>[src]

impl<IN, F: Fn(IN) + 'static> From<F> for Callback<IN>[src]

impl<IN> PartialEq<Callback<IN>> for Callback<IN>[src]

Auto Trait Implementations

impl<IN> !RefUnwindSafe for Callback<IN>

impl<IN> !Send for Callback<IN>

impl<IN> !Sync for Callback<IN>

impl<IN> Unpin for Callback<IN>

impl<IN> !UnwindSafe for Callback<IN>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.