Reduce Operator

February 25, 2020 ยท View on GitHub

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

  • WithContext

  • WithObservationStrategy

  • WithErrorStrategy

  • WithPool

  • WithCPUPool

  • WithPublishStrategy

Contents

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