pub struct UseRef<T> { /* private fields */ }
Expand description

A type created by the use_ref hook. See its documentation for more details.

Implementations

Read the value in the RefCell into a Ref. If this method is called while other values are still being read or write, then your app will crash.

Be very careful when working with this method. If you can, consider using the with and with_mut methods instead, choosing to render Elements during the read calls.

Mutably unlock the value in the RefCell. This will mark the component as “dirty”

Uses to write should be as short as possible.

Be very careful when working with this method. If you can, consider using the with and with_mut methods instead, choosing to render Elements during the read and write calls.

Set the curernt value to new_value. This will mark the component as “dirty”

This change will propogate immediately, so any other contexts that are using this RefCell will also be affected. If called during an async context, the component will not be re-rendered until the next .await call.

Mutably unlock the value in the RefCell. This will not mark the component as dirty. This is useful if you want to do some work without causing the component to re-render.

Uses to write should be as short as possible.

Be very careful when working with this method. If you can, consider using the with and with_mut methods instead, choosing to render Elements

Take a reference to the inner value termporarily and produce a new value

Note: You can always “reborrow” the value through the RefCell. This method just does it for you automatically.

let val = use_ref(|| HashMap::<u32, String>::new());


// use reborrowing
let inner = &*val.read();

// or, be safer and use `with`
val.with(|i| println!("{:?}", i));

Take a reference to the inner value termporarily and produce a new value, modifying the original in place.

Note: You can always “reborrow” the value through the RefCell. This method just does it for you automatically.

let val = use_ref(|| HashMap::<u32, String>::new());


// use reborrowing
let inner = &mut *val.write();

// or, be safer and use `with`
val.with_mut(|i| i.insert(1, "hi"));

Call the inner callback to mark the originator component as dirty.

This will cause the component to be re-rendered after the current scope has ended or the current async task has been yielded through await.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.