Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 781 Bytes

scan.md

File metadata and controls

41 lines (28 loc) · 781 Bytes

Scan Operator

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