Treatment trigger

std/flow::trigger


Generics

◻ T (any)

Inputs

⇥ stream: Stream<T>

Outputs

↦ end: Block<void>
↦ first: Block<T>
↦ last: Block<T>
↦ start: Block<void>


Trigger on a stream start and end.

Emit start when a first value is send through the stream. Emit end when stream is finally over.

Emit first with the first value coming in the stream. Emit last with the last value coming in the stream.

ℹ️ start and first are always emitted together. If the stream only contains one element, first and last both contains it. If the stream never transmit any data before being ended, only end is emitted.

graph LR
     T("trigger()")
     B["🟥 … 🟨 🟨 🟨 🟨 🟨 🟨 … 🟩"] -->|stream| T
     
     T -->|start| S["〈🟦〉"]
     T -->|first| F["〈🟩〉"]
     T -->|last| L["〈🟥〉"]
     T -->|end| E["〈🟦〉"]

     style B fill:#ffff,stroke:#ffff
     style S fill:#ffff,stroke:#ffff
     style F fill:#ffff,stroke:#ffff
     style L fill:#ffff,stroke:#ffff
     style E fill:#ffff,stroke:#ffff