pub struct ServerAction<S>{ /* private fields */ }
Expand description
An Action
that can be used to call a server function.
Implementations§
Methods from Deref<Target = Action<S, Result<<S as ServerFn>::Output, ServerFnError<<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 version(&self) -> RwSignal<usize>
pub fn version(&self) -> RwSignal<usize>
The number of times the action has successfully completed.
let act = Action::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 pending(&self) -> Memo<bool>
pub fn pending(&self) -> Memo<bool>
Whether the action has been dispatched and is currently waiting to resolve.
let act = Action::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);
Sourcepub fn input(&self) -> RwSignal<Option<I>>
pub fn input(&self) -> RwSignal<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 input_local(&self) -> RwSignal<Option<I>, LocalStorage>
pub fn input_local(&self) -> RwSignal<Option<I>, LocalStorage>
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.
Returns a thread-local signal using LocalStorage
.
Sourcepub fn value(&self) -> RwSignal<Option<O>>
pub fn value(&self) -> RwSignal<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 = Action::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 value_local(&self) -> RwSignal<Option<O>, LocalStorage>
pub fn value_local(&self) -> RwSignal<Option<O>, LocalStorage>
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.
Returns a thread-local signal using LocalStorage
.
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.
Trait Implementations§
Source§impl<S> Clone for ServerAction<S>
impl<S> Clone for ServerAction<S>
Source§fn clone(&self) -> ServerAction<S>
fn clone(&self) -> ServerAction<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 ServerAction<S>
impl<S> Default for ServerAction<S>
Source§fn default() -> ServerAction<S>
fn default() -> ServerAction<S>
Source§impl<S> DefinedAt for ServerAction<S>
impl<S> DefinedAt for ServerAction<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 ServerAction<S>
impl<S> Deref for ServerAction<S>
Source§impl<S> From<ServerAction<S>> for Action<S, Result<<S as ServerFn>::Output, ServerFnError<<S as ServerFn>::Error>>>
impl<S> From<ServerAction<S>> for Action<S, Result<<S as ServerFn>::Output, ServerFnError<<S as ServerFn>::Error>>>
impl<S> Copy for ServerAction<S>
Auto Trait Implementations§
impl<S> Freeze for ServerAction<S>
impl<S> RefUnwindSafe for ServerAction<S>
impl<S> Send for ServerAction<S>
impl<S> Sync for ServerAction<S>
impl<S> Unpin for ServerAction<S>
impl<S> UnwindSafe for ServerAction<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