Apply a function to each item emitted by an Observable, sequentially, and emit the final value.
observable := rxgo.Just(1, 2, 3)().
Reduce(func(_ context.Context, acc interface{}, elem interface{}) (interface{}, error) {
if acc == nil {
return elem, nil
}
return acc.(int) + elem.(int), nil
})
Output:
6