Struct leptos_server::ArcServerAction

source ·
pub struct ArcServerAction<S>
where S: ServerFn + 'static, S::Output: 'static,
{ /* private fields */ }

Implementations§

source§

impl<S> ArcServerAction<S>
where S: ServerFn + Clone + Send + Sync + 'static, S::Output: Send + Sync + 'static, S::Error: Send + Sync + 'static,

source

pub fn new() -> Self

Methods from Deref<Target = ArcAction<S, Result<S::Output, ServerFnError<S::Error>>>>§

source

pub fn dispatch(&self, input: I) -> ActionAbortHandle

Calls the async function with a reference to the input type as its argument.

source

pub fn dispatch_local(&self, input: I) -> ActionAbortHandle

Calls the async function with a reference to the input type as its argument, ensuring that it is spawned on the current thread.

source

pub fn version(&self) -> ArcRwSignal<usize>

The number of times the action has successfully completed.

let act = ArcAction::new(|n: &u8| {
    let n = n.to_owned();
    async move { n * 2 }
});

let version = act.version();
act.dispatch(3);
assert_eq!(version.get(), 0);

// after it resolves
assert_eq!(version.get(), 1);
source

pub fn input(&self) -> ArcRwSignal<Option<I>>

The current argument that was dispatched to the async function. This value will be Some while we are waiting for it to resolve, and None after it has resolved.

let act = ArcAction::new(|n: &u8| {
    let n = n.to_owned();
    async move { n * 2 }
});

let input = act.input();
assert_eq!(input.get(), None);
act.dispatch(3);
assert_eq!(input.get(), Some(3));

// after it resolves
assert_eq!(input.get(), None);
source

pub fn value(&self) -> ArcRwSignal<Option<O>>

The most recent return value of the async function. This will be None before the action has ever run successfully, and subsequently will always be Some(_), holding the old value until a new value has been received.

let act = ArcAction::new(|n: &u8| {
    let n = n.to_owned();
    async move { n * 2 }
});

let value = act.value();
assert_eq!(value.get(), None);
act.dispatch(3);
assert_eq!(value.get(), None);

// after it resolves
assert_eq!(value.get(), Some(6));
// dispatch another value, and it still holds the old value
act.dispatch(3);
assert_eq!(value.get(), Some(6));
source

pub fn pending(&self) -> ArcMemo<bool>

Whether the action has been dispatched and is currently waiting to resolve.

let act = ArcAction::new(|n: &u8| {
    let n = n.to_owned();
    async move { n * 2 }
});

let pending = act.pending();
assert_eq!(pending.get(), false);
act.dispatch(3);
assert_eq!(pending.get(), true);

// after it resolves
assert_eq!(pending.get(), false);

Trait Implementations§

source§

impl<S> Clone for ArcServerAction<S>
where S: ServerFn + 'static, S::Output: 'static,

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<S> Default for ArcServerAction<S>
where S: ServerFn + Clone + Send + Sync + 'static, S::Output: Send + Sync + 'static, S::Error: Send + Sync + 'static,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<S> DefinedAt for ArcServerAction<S>
where S: ServerFn + 'static, S::Output: 'static,

source§

fn defined_at(&self) -> Option<&'static Location<'static>>

Returns the location at which the signal was defined. This is usually simply None in release mode.
source§

impl<S> Deref for ArcServerAction<S>
where S: ServerFn + 'static, S::Output: 'static,

§

type Target = ArcAction<S, Result<<S as ServerFn>::Output, ServerFnError<<S as ServerFn>::Error>>>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<S> Freeze for ArcServerAction<S>

§

impl<S> !RefUnwindSafe for ArcServerAction<S>

§

impl<S> Send for ArcServerAction<S>
where S: Sync, <S as ServerFn>::Output: Sync, <S as ServerFn>::Error: Send + Sync,

§

impl<S> Sync for ArcServerAction<S>
where S: Sync, <S as ServerFn>::Output: Sync, <S as ServerFn>::Error: Send + Sync,

§

impl<S> Unpin for ArcServerAction<S>

§

impl<S> !UnwindSafe for ArcServerAction<S>

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.