Memo

Struct Memo 

pub struct Memo<T>
where T: PartialEq + 'static,
{ /* private fields */ }
Expand description

A memoized derived value that only recomputes when one of its tracked dependencies changes, and only notifies dependents when its value changes.

Unlike the previous implementation, this is driven by dependency invalidation rather than an Effect that eagerly recomputes.

Implementations§

§

impl<T> Memo<T>
where T: PartialEq + 'static,

Create a Memo which takes the computed value of the given function, and triggers the reactive system when the computed value is different from the last computed value.

pub fn new(f: impl Fn(Option<&T>) -> T + 'static) -> Memo<T>

Trait Implementations§

§

impl<T> Add<T> for Memo<T>
where T: 'static + PartialEq + Add<Output = T>, &'a T: for<'a> Add<T, Output = T>,

§

type Output = T

The resulting type after applying the + operator.
§

fn add(self, rhs: T) -> <Memo<T> as Add<T>>::Output

Performs the + operation. Read more
§

impl<T> BitAnd<T> for Memo<T>
where T: 'static + PartialEq + BitAnd<Output = T>, &'a T: for<'a> BitAnd<T, Output = T>,

§

type Output = T

The resulting type after applying the & operator.
§

fn bitand(self, rhs: T) -> <Memo<T> as BitAnd<T>>::Output

Performs the & operation. Read more
§

impl<T> BitOr<T> for Memo<T>
where T: 'static + PartialEq + BitOr<Output = T>, &'a T: for<'a> BitOr<T, Output = T>,

§

type Output = T

The resulting type after applying the | operator.
§

fn bitor(self, rhs: T) -> <Memo<T> as BitOr<T>>::Output

Performs the | operation. Read more
§

impl<T> BitXor<T> for Memo<T>
where T: 'static + PartialEq + BitXor<Output = T>, &'a T: for<'a> BitXor<T, Output = T>,

§

type Output = T

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: T) -> <Memo<T> as BitXor<T>>::Output

Performs the ^ operation. Read more
§

impl<T> Clone for Memo<T>
where T: PartialEq + 'static,

§

fn clone(&self) -> Memo<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Display for Memo<T>
where T: Display + 'static + PartialEq,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Div<T> for Memo<T>
where T: 'static + PartialEq + Div<Output = T>, &'a T: for<'a> Div<T, Output = T>,

§

type Output = T

The resulting type after applying the / operator.
§

fn div(self, rhs: T) -> <Memo<T> as Div<T>>::Output

Performs the / operation. Read more
§

impl<T> Mul<T> for Memo<T>
where T: 'static + PartialEq + Mul<Output = T>, &'a T: for<'a> Mul<T, Output = T>,

§

type Output = T

The resulting type after applying the * operator.
§

fn mul(self, rhs: T) -> <Memo<T> as Mul<T>>::Output

Performs the * operation. Read more
§

impl<T> Neg for Memo<T>
where T: 'static + PartialEq, &'a T: for<'a> Neg<Output = T>,

§

type Output = T

The resulting type after applying the - operator.
§

fn neg(self) -> <Memo<T> as Neg>::Output

Performs the unary - operation. Read more
§

impl<T> Not for Memo<T>
where T: 'static + PartialEq, &'a T: for<'a> Not<Output = T>,

§

type Output = T

The resulting type after applying the ! operator.
§

fn not(self) -> <Memo<T> as Not>::Output

Performs the unary ! operation. Read more
§

impl<T> PartialEq<T> for Memo<T>
where T: PartialEq + 'static,

§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> Rem<T> for Memo<T>
where T: 'static + PartialEq + Rem<Output = T>, &'a T: for<'a> Rem<T, Output = T>,

§

type Output = T

The resulting type after applying the % operator.
§

fn rem(self, rhs: T) -> <Memo<T> as Rem<T>>::Output

Performs the % operation. Read more
Source§

impl<T> Res<T> for Memo<T>
where T: Clone + PartialEq + 'static,

Source§

fn get_value(&self, _: &impl DataContext) -> T

Returns the value of a resource by value.
Source§

fn set_or_bind<F>(self, cx: &mut Context, closure: F)
where F: 'static + Fn(&mut Context, Memo<T>),

Source§

fn to_signal(self, cx: &mut Context) -> Signal<T>
where Self: Sized + 'static, T: Clone + 'static,

Converts this signal into a signal mirror tied to entity. Read more
§

impl<T> Shl<T> for Memo<T>
where T: 'static + PartialEq + Shl<Output = T>, &'a T: for<'a> Shl<T, Output = T>,

§

type Output = T

The resulting type after applying the << operator.
§

fn shl(self, rhs: T) -> <Memo<T> as Shl<T>>::Output

Performs the << operation. Read more
§

impl<T> Shr<T> for Memo<T>
where T: 'static + PartialEq + Shr<Output = T>, &'a T: for<'a> Shr<T, Output = T>,

§

type Output = T

The resulting type after applying the >> operator.
§

fn shr(self, rhs: T) -> <Memo<T> as Shr<T>>::Output

Performs the >> operation. Read more
§

impl<T> SignalGet<T> for Memo<T>
where T: Clone + PartialEq + 'static, ReadSignal<T>: SignalGet<T>,

§

fn id(&self) -> Id

get the Signal Id
§

fn get_untracked(&self) -> T
where T: 'static,

§

fn get(&self) -> T
where T: 'static,

§

fn try_get(&self) -> Option<T>
where T: 'static,

§

fn try_get_untracked(&self) -> Option<T>
where T: 'static,

§

impl<T> SignalTrack<T> for Memo<T>
where T: PartialEq + 'static,

§

fn id(&self) -> Id

§

fn track(&self)

Only subscribes to the current running effect to this Signal.
§

fn try_track(&self)

If the signal isn’t disposed,
§

impl<T> SignalWith<T> for Memo<T>
where T: PartialEq + 'static, ReadSignal<T>: SignalWith<T>,

§

fn id(&self) -> Id

get the Signal Id
§

fn with<O>(&self, f: impl FnOnce(&T) -> O) -> O
where T: 'static,

§

fn with_untracked<O>(&self, f: impl FnOnce(&T) -> O) -> O
where T: 'static,

§

fn try_with<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> O
where T: 'static,

§

fn try_with_untracked<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> O
where T: 'static,

§

impl<T> Sub<T> for Memo<T>
where T: 'static + PartialEq + Sub<Output = T>, &'a T: for<'a> Sub<T, Output = T>,

§

type Output = T

The resulting type after applying the - operator.
§

fn sub(self, rhs: T) -> <Memo<T> as Sub<T>>::Output

Performs the - operation. Read more
§

impl<T> Copy for Memo<T>
where T: PartialEq + 'static,

Auto Trait Implementations§

§

impl<T> Freeze for Memo<T>

§

impl<T> RefUnwindSafe for Memo<T>
where T: RefUnwindSafe,

§

impl<T> Send for Memo<T>
where T: Send,

§

impl<T> Sync for Memo<T>
where T: Sync,

§

impl<T> Unpin for Memo<T>
where T: Unpin,

§

impl<T> UnwindSafe for Memo<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T, S> SignalMap<T> for S
where T: 'static, S: SignalWith<T> + Copy + 'static,

§

fn map<U, F>(self, map: F) -> Memo<U>
where U: Clone + PartialEq + 'static, F: 'static + Fn(&T) -> U,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringLocalized for T
where T: ToString,

Source§

fn to_string_local(&self, _cx: &impl DataContext) -> String

Method for converting the current type to a String via a translation using fluent.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,