Struct maple_core::prelude::SignalVec[][src]

pub struct SignalVec<T: 'static> { /* fields omitted */ }

A reactive Vec. This is more effective than using a Signal<Vec> because it allows fine grained reactivity within the Vec.

Implementations

impl<T: 'static> SignalVec<T>[src]

pub fn new() -> Self[src]

Create a new empty SignalVec.

pub fn with_values(values: Vec<T>) -> Self[src]

Create a new SignalVec with existing values from a Vec.

pub fn changes(&self) -> &Rc<RefCell<Vec<VecDiff<T>>>>[src]

Get the current pending changes that will be applied to the SignalVec.

pub fn inner_signal(&self) -> &Signal<RefCell<Vec<T>>>[src]

Returns the inner backing Signal used to store the data. This method should used with care as unintentionally modifying the Vec will not trigger any updates and cause potential future problems.

pub fn replace(&self, values: Vec<T>)[src]

pub fn insert(&self, index: usize, value: T)[src]

pub fn update(&self, index: usize, value: T)[src]

pub fn remove(&self, index: usize)[src]

pub fn swap(&self, index1: usize, index2: usize)[src]

pub fn push(&self, value: T)[src]

pub fn pop(&self)[src]

pub fn clear(&self)[src]

pub fn map<U: Clone>(&self, f: impl Fn(&T) -> U + 'static) -> SignalVec<U>[src]

Creates a derived SignalVec.

Example

use maple_core::prelude::*;

let my_vec = SignalVec::with_values(vec![1, 2, 3]);
let squared = my_vec.map(|x| *x * *x);

assert_eq!(*squared.inner_signal().get().borrow(), vec![1, 4, 9]);

my_vec.push(4);
assert_eq!(*squared.inner_signal().get().borrow(), vec![1, 4, 9, 16]);

my_vec.swap(0, 1);
assert_eq!(*squared.inner_signal().get().borrow(), vec![4, 1, 9, 16]);

impl SignalVec<TemplateResult>[src]

pub fn template_list(&self) -> TemplateList[src]

Create a TemplateList from the SignalVec.

impl<T: 'static + Clone> SignalVec<T>[src]

pub fn to_vec(&self) -> Vec<T>[src]

Create a Vec from a SignalVec. The returned Vec is cloned from the data which requires T to be Clone.

Example

use maple_core::prelude::*;

let signal = SignalVec::with_values(vec![1, 2, 3]);
assert_eq!(signal.to_vec(), vec![1, 2, 3]);

Trait Implementations

impl<T: 'static> Clone for SignalVec<T>[src]

impl<T: 'static> Default for SignalVec<T>[src]

impl From<SignalVec<TemplateResult>> for TemplateList[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for SignalVec<T>

impl<T> !Send for SignalVec<T>

impl<T> !Sync for SignalVec<T>

impl<T> Unpin for SignalVec<T>

impl<T> !UnwindSafe for SignalVec<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.