KeepLastOutput

h8io.stages.operators.KeepLastOutput

A decorator that remembers the last output produced by the inner stage and re-emits it when the inner stage yields no value.

The decorator has two internal states:

  • None state (initial): no output has been seen yet. The inner stage's h8io.stages.Yield.None is forwarded unchanged; a h8io.stages.Yield.Some is forwarded and transitions the wrapper to the Some state.
  • Some state: a previous output out is remembered, so the wrapper always emits a value. A new h8io.stages.Yield.Some from the inner stage is forwarded as is and updates the remembered value; on h8io.stages.Yield.None the remembered value is emitted instead.

In both states the evolution is mapped so that continuations remain wrapped in the appropriate KeepLastOutput variant, preserving the last-value semantics.

Both variants are internal to the package: the decorator is reached through the KeepLastOutput.apply factory, which always starts in the None state, and the state it is in afterwards is not part of the API.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def apply[I, O, E](stage: Stage[I, O, E]): Stage[I, O, E]

Wraps stage in a KeepLastOutput starting in the initial (no remembered value) state.

Wraps stage in a KeepLastOutput starting in the initial (no remembered value) state.

Type parameters

E

the error type

I

the input type

O

the output type

Value parameters

stage

the stage to wrap

Attributes

Returns

a stage that re-emits the last seen output when the inner stage yields nothing