Skip to content

Latest commit

 

History

History
70 lines (60 loc) · 3.39 KB

De-Materialize.md

File metadata and controls

70 lines (60 loc) · 3.39 KB

Materialize / Dematerialize

A Callbag operator that will represent both the items emitted and the completion sent as emitted items, or reverse this process. And it returns a pullable / listenable source, depends on the given callbag sources types.

Examples

  _ = of(1, 2, 3, 4, 5)
    |> materialize()
    |> forEach(print) // next(1)
                      // next(2)
                      // next(3)
                      // next(4)
                      // next(5)
                      // completed(.finished)
  let materialized = (1...5).map {
    Sink<Int>.next($0)
  } + [ Sink<Int>.completed(.finished) ]

  _ = from(materialized)
    |> dematerialize()
    |> forEach(print) // 1
                      // 2
                      // 3
                      // 4
                      // 5