Skip to main content

FuncAddEventHandler

Struct FuncAddEventHandler 

Source
pub struct FuncAddEventHandler<TTarget, TEventArgs, TToken = Rc<dyn IDisposable>> { /* private fields */ }
Expand description

An IAddEventHandler for the event name of sources of type TTarget, from a function that subscribes a handler and a function that removes it.

TTarget is the handle of the source (Ref<Button>, Rc<Model>). Deviation (DEVIATIONS.md, Behaviors): the reference removes a handler by delegate identity; a subscription of the port returns a token (TToken: a routed event handler token, a disposable), which is what remove takes.

Implementations§

Source§

impl<TTarget, TEventArgs, TToken> FuncAddEventHandler<TTarget, TEventArgs, TToken>
where TTarget: Clone + 'static, TEventArgs: EventArgsValue + 'static, TToken: 'static,

Source

pub fn new( name: &str, add: impl Fn(&TTarget, EventHandler<TEventArgs>) -> TToken + 'static, remove: impl Fn(&TTarget, TToken) + 'static, ) -> Self

Creates the handler of the event name: add subscribes a handler to a source, remove removes it with the token add returned.

Trait Implementations§

Source§

impl<TTarget, TEventArgs, TToken> IAddEventHandler for FuncAddEventHandler<TTarget, TEventArgs, TToken>
where TTarget: Clone + 'static, TEventArgs: EventArgsValue + 'static, TToken: 'static,

Source§

fn matches(&self, source: &BoxedValue, event_name: &str) -> bool

Checks if the given source object and event name match the criteria for this event handler.
Source§

fn add_handler( &self, source: &BoxedValue, event_name: &str, handler: AddEventHandlerCallback, ) -> Option<Rc<dyn IDisposable>>

Registers an event handler for a specific event on the given source object. Disposing the returned handle removes it; None when the source or the event does not match.

Auto Trait Implementations§

§

impl<TTarget, TEventArgs, TToken = Rc<dyn IDisposable>> !RefUnwindSafe for FuncAddEventHandler<TTarget, TEventArgs, TToken>

§

impl<TTarget, TEventArgs, TToken = Rc<dyn IDisposable>> !Send for FuncAddEventHandler<TTarget, TEventArgs, TToken>

§

impl<TTarget, TEventArgs, TToken = Rc<dyn IDisposable>> !Sync for FuncAddEventHandler<TTarget, TEventArgs, TToken>

§

impl<TTarget, TEventArgs, TToken = Rc<dyn IDisposable>> !UnwindSafe for FuncAddEventHandler<TTarget, TEventArgs, TToken>

§

impl<TTarget, TEventArgs, TToken> Freeze for FuncAddEventHandler<TTarget, TEventArgs, TToken>
where Box<dyn Fn(&TTarget, Rc<dyn Fn(Option<&Rc<dyn AnyValue>>, &TEventArgs)>) -> TToken>: Freeze, Rc<dyn Fn(&TTarget, TToken)>: Freeze,

§

impl<TTarget, TEventArgs, TToken> Unpin for FuncAddEventHandler<TTarget, TEventArgs, TToken>
where Box<dyn Fn(&TTarget, Rc<dyn Fn(Option<&Rc<dyn AnyValue>>, &TEventArgs)>) -> TToken>: Unpin, Rc<dyn Fn(&TTarget, TToken)>: Unpin,

§

impl<TTarget, TEventArgs, TToken> UnsafeUnpin for FuncAddEventHandler<TTarget, TEventArgs, TToken>
where Box<dyn Fn(&TTarget, Rc<dyn Fn(Option<&Rc<dyn AnyValue>>, &TEventArgs)>) -> TToken>: UnsafeUnpin, Rc<dyn Fn(&TTarget, TToken)>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.