Apply a function to each item emitted by an Observable, sequentially, and emit each successive value.
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