Trait JsObserve

Source
pub trait JsObserve: DynClone {
    // Required methods
    fn get_js(&self) -> JsValue;
    fn unsubscribe(&self, handle: ListenerHandle) -> bool;
    fn subscribe(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle;
    fn once(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle;

    // Provided method
    fn map_js(&self, cb: Function) -> JsValue { ... }
}
Expand description

This trait is necessary to support generic observables which cannot themselves be exportable via wasm_bindgen

Required Methods§

Source

fn get_js(&self) -> JsValue

Source

fn unsubscribe(&self, handle: ListenerHandle) -> bool

Source

fn subscribe(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle

Source

fn once(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle

Provided Methods§

Source

fn map_js(&self, cb: Function) -> JsValue

The default implementation of map is to call the closure once with the output of .get - other types may call the closure multiple times for different sub-values

Implementations on Foreign Types§

Source§

impl<T> JsObserve for Observable<List<T>>
where T: Into<JsValue> + Clone,

Source§

fn get_js(&self) -> JsValue

Source§

fn subscribe(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle

Source§

fn once(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle

Source§

fn unsubscribe(&self, handle: ListenerHandle) -> bool

Source§

impl<T> JsObserve for Observable<T>
where T: Into<JsValue> + Clone,

Source§

fn get_js(&self) -> JsValue

Source§

fn subscribe(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle

Source§

fn once(&self, cb: Box<dyn Fn(JsValue)>) -> ListenerHandle

Source§

fn unsubscribe(&self, handle: ListenerHandle) -> bool

Implementors§