Scan Operator

February 25, 2020 ยท View on GitHub

Overview

Apply a function to each item emitted by an Observable, sequentially, and emit each successive value.

Example

observable := rxgo.Just(1, 2, 3, 4, 5)().
    Scan(func(_ context.Context, acc interface{}, elem interface{}) (interface{}, error) {
        if acc == nil {
            return elem, nil
        }
        return acc.(int) + elem.(int), nil
    })

Output:

1
3
6
10
15

Options

  • WithBufferedChannel

  • WithContext

  • WithObservationStrategy

  • WithErrorStrategy

  • WithPublishStrategy

Contents

  1. 1Overview
  2. 2Example
  3. 3Options