Skip to content

Latest commit

 

History

History
55 lines (33 loc) · 878 Bytes

reduce.md

File metadata and controls

55 lines (33 loc) · 878 Bytes

Reduce Operator

Overview

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

Example

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

Options

WithBufferedChannel

Detail

WithContext

Detail

WithObservationStrategy

Detail

WithErrorStrategy

Detail

WithPool

Detail

WithCPUPool

Detail

WithPublishStrategy

Detail