Struct leptos_server::ArcServerAction
source · pub struct ArcServerAction<S>{ /* private fields */ }Implementations§
Methods from Deref<Target = ArcAction<S, Result<S::Output, ServerFnError<S::Error>>>>§
sourcepub fn dispatch(&self, input: I) -> ActionAbortHandle
pub fn dispatch(&self, input: I) -> ActionAbortHandle
Calls the async function with a reference to the input type as its argument.
sourcepub fn dispatch_local(&self, input: I) -> ActionAbortHandle
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.
sourcepub fn version(&self) -> ArcRwSignal<usize>
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);sourcepub fn input(&self) -> ArcRwSignal<Option<I>>
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);sourcepub fn value(&self) -> ArcRwSignal<Option<O>>
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));sourcepub fn pending(&self) -> ArcMemo<bool>
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>
impl<S> Clone for ArcServerAction<S>
source§impl<S> Default for ArcServerAction<S>
impl<S> Default for ArcServerAction<S>
source§impl<S> DefinedAt for ArcServerAction<S>
impl<S> DefinedAt for ArcServerAction<S>
source§fn defined_at(&self) -> Option<&'static Location<'static>>
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.Auto Trait Implementations§
impl<S> Freeze for ArcServerAction<S>
impl<S> !RefUnwindSafe for ArcServerAction<S>
impl<S> Send for ArcServerAction<S>
impl<S> Sync for ArcServerAction<S>
impl<S> Unpin for ArcServerAction<S>
impl<S> !UnwindSafe for ArcServerAction<S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.