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 Schedulers — able to apply modifiers to when (and how often) Actions. are sent.

Required Associated Types§

source

type Action

The Action sends scheduled by this Scheduler.

Provided Methods§

source

fn after(&self, duration: Duration, action: Self::Action) -> Task
where Self::Action: Clone + 'static,

Sends the Action after duration.

source

fn at(&self, instant: Instant, action: Self::Action) -> Task
where Self::Action: Clone + 'static,

Sends the Action at instant.

source

fn every(&self, interval: Interval, action: Self::Action) -> Task
where Self::Action: Clone + 'static,

Sends the Action every interval.

source

fn debounce( &self, action: Self::Action, previous: &mut Option<Task>, interval: Interval, )
where Self::Action: Clone + 'static,

An effect that coalesces repeated attempts to send Actions through the Store’s Reducer into a singe send. Once timeout has elapsed with no further Actions 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.

source

fn throttle( &self, action: Self::Action, previous: &mut Option<Task>, interval: Interval, )
where Self::Action: Clone + 'static,

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.

Object Safety§

This trait is not object safe.

Implementors§