Skip to main content

RenderEffect

Struct RenderEffect 

Source
pub struct RenderEffect<T>
where T: 'static,
{ /* private fields */ }
Expand description

A render effect is similar to an Effect, but with two key differences:

  1. Its first run takes place immediately and synchronously: for example, if it is being used to drive a user interface, it will run during rendering, not on the next tick after rendering. (Hence “render effect.”)
  2. It is canceled when the RenderEffect itself is dropped, rather than being stored in the reactive system and canceled when the Owner cleans up.

Unless you are implementing a rendering framework, or require one of these two characteristics, it is unlikely you will use render effects directly.

Like an Effect, a render effect runs only with the effects feature enabled.

Implementations§

Source§

impl<T> RenderEffect<T>
where T: 'static,

Source

pub fn new(fun: impl FnMut(Option<T>) -> T + 'static) -> RenderEffect<T>

Creates a new render effect, which immediately runs fun.

Source

pub fn new_with_value( fun: impl FnMut(Option<T>) -> T + 'static, initial_value: Option<T>, ) -> RenderEffect<T>

Creates a new render effect with an initial value.

Source

pub async fn new_with_async_value( fun: impl FnMut(Option<T>) -> T + 'static, value: impl IntoFuture<Output = T> + 'static, ) -> RenderEffect<T>

Creates a new render effect, which immediately runs fun.

Source

pub fn with_value_mut<U>(&self, fun: impl FnOnce(&mut T) -> U) -> Option<U>

Mutably accesses the current value.

Source

pub fn take_value(&self) -> Option<T>

Takes the current value, replacing it with None.

Source§

impl<T> RenderEffect<T>
where T: Send + Sync + 'static,

Source

pub fn new_isomorphic( fun: impl FnMut(Option<T>) -> T + Send + Sync + 'static, ) -> RenderEffect<T>

Creates a render effect that will run whether the effects feature is enabled or not.

Trait Implementations§

Source§

impl<T> Debug for RenderEffect<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> From<RenderEffect<T>> for RenderEffectState<T>

Source§

fn from(value: RenderEffect<T>) -> RenderEffectState<T>

Converts to this type from the input type.
Source§

impl<M> Mountable for RenderEffect<M>
where M: Mountable + 'static,

Source§

fn unmount(&mut self)

Detaches the view from the DOM.
Source§

fn mount(&mut self, parent: &Element, marker: Option<&Node>)

Mounts a node to the interface.
Source§

fn insert_before_this(&self, child: &mut dyn Mountable) -> bool

Inserts another Mountable type before this one. Returns false if this does not actually exist in the UI (for example, ()).
Source§

fn elements(&self) -> Vec<Element>

wip
Source§

fn try_mount(&mut self, parent: &Element, marker: Option<&Node>) -> bool

Mounts a node to the interface. Returns false if it could not be mounted.
Source§

fn insert_before_this_or_marker( &self, parent: &Element, child: &mut dyn Mountable, marker: Option<&Node>, )

Inserts another Mountable type before this one, or before the marker if this one doesn’t exist in the UI (for example, ()).
Source§

impl<T> ToAnySubscriber for RenderEffect<T>

Source§

fn to_any_subscriber(&self) -> AnySubscriber

Converts this type to its type-erased equivalent.

Auto Trait Implementations§

§

impl<T> Freeze for RenderEffect<T>

§

impl<T> RefUnwindSafe for RenderEffect<T>

§

impl<T> Send for RenderEffect<T>
where T: Send + Sync,

§

impl<T> Sync for RenderEffect<T>
where T: Send + Sync,

§

impl<T> Unpin for RenderEffect<T>

§

impl<T> UnwindSafe for RenderEffect<T>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<T> SerializableKey for T

Source§

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
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.