Skip to content

struct

Memo

pub struct Memo<T: 'static> {
    /* private fields */
}

A cached derived value. Readers are only notified when the computed value actually changes (by PartialEq).

Methods

new

pub fn new(f: impl FnMut() -> T + 'static) -> Self

Create a memo computing its value from f.

get

pub fn get(&self) -> T

Read the current value, subscribing the current effect.

get_untracked

pub fn get_untracked(&self) -> T

Read the current value without subscribing.

with

pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R

Borrow the current value, subscribing the current effect.

Trait implementations