Struct DerivedRwSignal

Source
pub struct DerivedRwSignal<T: 'static, O, GF: Fn(&T) -> O + Clone + 'static, UF: Fn(&O) -> T + 'static> { /* private fields */ }
Expand description

A signal that is derived from an RwSignal but lets you specify getters and setters for the signal.

This is useful when you want a single state variable and don’t want to use effects to synchronize multiple signals.

This is also useful when you want a derived signal that implements the SignalGet, SignalWith, etc. traits.

Implementations§

Source§

impl<T, O, GF, UF> DerivedRwSignal<T, O, GF, UF>
where GF: Fn(&T) -> O + Clone + 'static, UF: Fn(&O) -> T + 'static,

Source

pub fn new(signal: RwSignal<T>, getter: GF, setter: UF) -> Self

Trait Implementations§

Source§

impl<T, O, GF: Fn(&T) -> O + Copy, UF: Fn(&O) -> T + Copy> Clone for DerivedRwSignal<T, O, GF, UF>

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<T: Clone + 'static, O: Clone, GF: Fn(&T) -> O + Copy, UF: Fn(&O) -> T + Copy> SignalGet<O> for DerivedRwSignal<T, O, GF, UF>

Source§

fn id(&self) -> Id

get the Signal Id
Source§

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

Try to clone and return the current value stored in the Signal, and returns None if it’s already disposed. It subscribes to the current running effect.
Source§

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

Try to clone and return the current value stored in the Signal, and returns None if it’s already disposed. It doesn’t subscribe to the current running effect.
Source§

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

Clones and returns the current value stored in the Signal, but it doesn’t subscribe to the current running effect.
Source§

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

Clones and returns the current value stored in the Signal, and subscribes to the current running effect to this Signal.
Source§

impl<T: Clone + 'static, O: Clone, GF: Fn(&T) -> O + Copy, UF: Fn(&O) -> T + Copy> SignalTrack<O> for DerivedRwSignal<T, O, GF, UF>

Source§

fn id(&self) -> Id

Source§

fn track(&self)

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

fn try_track(&self)

If the signal isn’t disposed,
Source§

impl<T: 'static, O, GF: Fn(&T) -> O + Copy, UF: Fn(&O) -> T + Copy> SignalUpdate<O> for DerivedRwSignal<T, O, GF, UF>

Source§

fn id(&self) -> Id

get the Signal Id
Source§

fn set(&self, new_value: O)
where O: 'static,

Sets the new_value to the Signal and triggers effect run
Source§

fn update(&self, f: impl FnOnce(&mut O))
where O: 'static,

Update the stored value with the given function and triggers effect run
Source§

fn try_update<O2>(&self, f: impl FnOnce(&mut O) -> O2) -> Option<O2>
where O: 'static,

Update the stored value with the given function, triggers effect run, and returns the value returned by the function
Source§

impl<T: Clone + 'static, O: Clone, GF: Fn(&T) -> O + Copy, UF: Fn(&O) -> T + Copy> SignalWith<O> for DerivedRwSignal<T, O, GF, UF>

Source§

fn id(&self) -> Id

get the Signal Id
Source§

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

Applies a closure to the current value stored in the Signal, and subscribes to the current running effect to this Memo.
Source§

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

Applies a closure to the current value stored in the Signal, but it doesn’t subscribe to the current running effect.
Source§

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

If the signal isn’t disposed, applies a closure to the current value stored in the Signal. It subscribes to the current running effect.
Source§

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

If the signal isn’t disposed, applies a closure to the current value stored in the Signal, but it doesn’t subscribe to the current running effect.
Source§

impl<T, O, GF: Fn(&T) -> O + Copy, UF: Fn(&O) -> T + Copy> Copy for DerivedRwSignal<T, O, GF, UF>

Auto Trait Implementations§

§

impl<T, O, GF, UF> Freeze for DerivedRwSignal<T, O, GF, UF>

§

impl<T, O, GF, UF> RefUnwindSafe for DerivedRwSignal<T, O, GF, UF>

§

impl<T, O, GF, UF> Send for DerivedRwSignal<T, O, GF, UF>
where T: Send, GF: Send, UF: Send,

§

impl<T, O, GF, UF> Sync for DerivedRwSignal<T, O, GF, UF>
where T: Sync, GF: Sync, UF: Sync,

§

impl<T, O, GF, UF> Unpin for DerivedRwSignal<T, O, GF, UF>
where T: Unpin,

§

impl<T, O, GF, UF> UnwindSafe for DerivedRwSignal<T, O, GF, UF>
where T: UnwindSafe, GF: UnwindSafe, UF: 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, dst: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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