Trait thaw_utils::SignalWatch

source ·
pub trait SignalWatch {
    type Value;

    // Required method
    fn watch(&self, f: impl Fn(&Self::Value) + 'static) -> Box<dyn FnOnce()>;
}

Required Associated Types§

Required Methods§

source

fn watch(&self, f: impl Fn(&Self::Value) + 'static) -> Box<dyn FnOnce()>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> SignalWatch for RwSignal<T>

source§

fn watch(&self, f: impl Fn(&Self::Value) + 'static) -> Box<dyn FnOnce()>

Listens for RwSignal changes and is not executed immediately

§Usage
use leptos::*;
use thaw::*;

let count = create_rw_signal(0);
let stop = count.watch(|count| {
    assert_eq!(count, &1);
});

count.set(1); // assert_eq!(count, &1);

stop(); // stop watching

count.set(2); // nothing happens
source§

type Value = T

Implementors§