pub struct ArcServerAction<S>{ /* private fields */ }Expand description
An ArcAction that can be used to call a server function.
Implementations§
Source§impl<S> ArcServerAction<S>
impl<S> ArcServerAction<S>
Sourcepub fn new() -> ArcServerAction<S>
pub fn new() -> ArcServerAction<S>
Creates a new ArcAction that will call the server function S when dispatched.
Methods from Deref<Target = ArcAction<S, Result<<S as ServerFn>::Output, <S as ServerFn>::Error>>>§
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears the value of the action, setting its current value to None.
This has no other effect: i.e., it will not cancel in-flight actions, set the input, etc.
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) -> ArcMappedSignal<Option<I>>
pub fn input(&self) -> ArcMappedSignal<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) -> ArcMappedSignal<Option<O>>
pub fn value(&self) -> ArcMappedSignal<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§fn clone(&self) -> ArcServerAction<S>
fn clone(&self) -> ArcServerAction<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S> Default for ArcServerAction<S>
impl<S> Default for ArcServerAction<S>
Source§fn default() -> ArcServerAction<S>
fn default() -> 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>>
None in
release mode.Source§impl<S> Deref for ArcServerAction<S>
impl<S> Deref for ArcServerAction<S>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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