Struct sodium_rust::Cell

source ·
pub struct Cell<A> {
    pub impl_: CellImpl<A>,
}
Expand description

Represents a value of type A that changes over time.

In other Functional Reactive Programming (FRP) systems this is also called a behavior, property, or a signal. A Cell should be used for modeling any pieces of mutable state in an FRP application.

Fields§

§impl_: CellImpl<A>

Implementations§

Create a Cell with a constant value.

Sample the Cell’s current value.

Cell::sample may be used in the functions passed to primitives that apply them to Streams, including Stream::map, Stream::snapshot, Stream::filter, and Stream::merge.

When called within a function passed to Stream::map using sample is equivalent to snapshotting this Cell with that Stream.

Sample the Cell’s current value lazily.

When it is necessary to use sample while implementing more general abstractions, sample_lazy should be preferred in case a CellLoop is passed rather than a Cell.

See Cell::sample for more details.

Return a Stream that gives the updates/steps for a Cell.

Important

This is an operational primitive, which isn’t part of the main Sodium API. It breaks the property of non-detectability of cell updates/steps. The rule with this primitive is that you should only use it in functions that don’t allow the caller to detect the Cell updates.

Return a Stream that is guaranteed to fire at least once.

When value is called, the returned Stream will fire once in the current transaction with the current value of this Cell and thereafter behaves like Cell::updates.

Important

This is an operational primitive, which isn’t part of the main Sodium API. It breaks the property of non-detectability of cell updates/steps. The rule with this primitive is that you should only use it in functions that don’t allow the caller to detect the Cell updates.

Transform the Cells value with the supplied function.

The returned Cell always reflects the value produced by the function applied to the input Cells value. The given function must be referentially transparent.

Lift a binary function into cells so the returned Cell always reflects the specified function applied to the input cells’ values.

Lift a ternary function into cells so the returned Cell always reflects the specified function applied to the input cells’ values.

Lift a quaternary function into cells so the returned Cell always reflects the specified function applied to the input cells’ values.

Lift a five-argument function into cells so the returned Cell always reflects the specified function applied to the input cells’ values.

Lift a six argument function into cells so the returned Cell always reflects the specified function applied to the input cells’ values.

Unwrap a Stream in a Cell to give a time-varying stream implementation.

Unwrap a Cell in another Cell to give a time-varying cell implementation.

A variant of listen that will deregister the listener automatically if the listener is garbage-collected.

Listen for updates to the value of this Cell.

This is the observer pattern. The returned Listener has an unlisten method to cause the listener to be removed.

This is an operational mechanism for interfacing between the world of I/O and FRP.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.