node/event_source/
event_source_actions.rs

1use serde::{Deserialize, Serialize};
2
3pub type EventSourceActionWithMeta = redux::ActionWithMeta<EventSourceAction>;
4
5#[derive(Serialize, Deserialize, Debug, Clone)]
6pub enum EventSourceAction {
7    /// Notify state machine that the new events might be received/available,
8    /// so trigger processing of those events.
9    ///
10    /// This action will be continuously triggered, until there are no more
11    /// events in the queue, in which case `EventSourceWaitForEventsAction`
12    /// will be dispatched.
13    ProcessEvents,
14
15    /// Process newly retrieved event.
16    NewEvent { event: super::Event },
17
18    /// Next action won't be dispatched, until new events are available or
19    /// wait times out.
20    WaitForEvents,
21
22    /// Waiting for events has timed out.
23    WaitTimeout,
24}
25
26impl redux::EnablingCondition<crate::State> for EventSourceAction {
27    fn is_enabled(&self, _: &crate::State, _time: redux::Timestamp) -> bool {
28        match self {
29            EventSourceAction::ProcessEvents => true,
30            EventSourceAction::NewEvent { event: _ } => true,
31            EventSourceAction::WaitForEvents => true,
32            EventSourceAction::WaitTimeout => true,
33        }
34    }
35}