pub struct Comparer<R, S = UnsyncStorage>where
R: 'static,
S: Storage<SignalData<bool>>,{ /* private fields */ }
Expand description
An object that can efficiently compare a value to a set of values.
Implementations§
§impl<R> Comparer<R>where
R: Eq + Hash,
impl<R> Comparer<R>where R: Eq + Hash,
pub fn new(f: impl FnMut() -> R + 'static) -> Comparer<R>
pub fn new(f: impl FnMut() -> R + 'static) -> Comparer<R>
Creates a new Comparer which efficiently tracks when a value changes to check if it is equal to a set of values.
Generally, you shouldn’t need to use this hook. Instead you can use crate::use_memo
. If you have many values that you need to compare to a single value, this hook will change updates from O(n) to O(1) where n is the number of values you are comparing to.
§impl<R, S> Comparer<R, S>where
R: Eq + Hash,
S: Storage<SignalData<bool>>,
impl<R, S> Comparer<R, S>where R: Eq + Hash, S: Storage<SignalData<bool>>,
pub fn new_maybe_sync(f: impl FnMut() -> R + 'static) -> Comparer<R>
pub fn new_maybe_sync(f: impl FnMut() -> R + 'static) -> Comparer<R>
Creates a new Comparer that may be Sync + Send
which efficiently tracks when a value changes to check if it is equal to a set of values.
Generally, you shouldn’t need to use this hook. Instead you can use crate::use_memo
. If you have many values that you need to compare to a single value, this hook will change updates from O(n) to O(1) where n is the number of values you are comparing to.
pub fn equal(&self, value: R) -> ReadOnlySignal<bool, S>
pub fn equal(&self, value: R) -> ReadOnlySignal<bool, S>
Returns a signal which is true when the value is equal to the value passed to this function.