Trait composable::effects::Scheduler
source · pub trait Scheduler {
type Action;
// Provided methods
fn after(&self, duration: Duration, action: Self::Action) -> Task
where Self::Action: Clone + 'static { ... }
fn at(&self, instant: Instant, action: Self::Action) -> Task
where Self::Action: Clone + 'static { ... }
fn every(&self, interval: Interval, action: Self::Action) -> Task
where Self::Action: Clone + 'static { ... }
fn debounce(
&self,
action: Self::Action,
previous: &mut Option<Task>,
interval: Interval,
)
where Self::Action: Clone + 'static { ... }
fn throttle(
&self,
action: Self::Action,
previous: &mut Option<Task>,
interval: Interval,
)
where Self::Action: Clone + 'static { ... }
}
Expand description
Effects
are also Scheduler
s — able to apply modifiers to when (and how often) Action
s. are sent.
Required Associated Types§
Provided Methods§
sourcefn after(&self, duration: Duration, action: Self::Action) -> Task
fn after(&self, duration: Duration, action: Self::Action) -> Task
Sends the Action
after duration
.
sourcefn every(&self, interval: Interval, action: Self::Action) -> Task
fn every(&self, interval: Interval, action: Self::Action) -> Task
Sends the Action
every interval
.
sourcefn debounce(
&self,
action: Self::Action,
previous: &mut Option<Task>,
interval: Interval,
)
fn debounce( &self, action: Self::Action, previous: &mut Option<Task>, interval: Interval, )
An effect that coalesces repeated attempts to send Action
s
through the Store
’s Reducer
into a singe send.
Once timeout
has elapsed with no further Action
s being attempted,
the last Action
will be sent.
The debounce
function will automatically update the information
stored in previous
as it runs. The Task
debounced by this call
will be the previous task for the next call, if any.
sourcefn throttle(
&self,
action: Self::Action,
previous: &mut Option<Task>,
interval: Interval,
)
fn throttle( &self, action: Self::Action, previous: &mut Option<Task>, interval: Interval, )
An effect that sends an Action
through the Store
’s
Reducer
if at least one interval
of time has passed
since previous
was sent. Otherwise, all subsequent actions but the last
are dropped until that time; which resets the countdown until the next
debounced action can be sent.
The throttle
function will automatically update the information
stored in previous
as it runs. The Task
throttled by this call
will be the previous task for the next call, if any.