Do Operator

February 25, 2020 ยท View on GitHub

Overview

Register an action to take upon a variety of Observable lifecycle events.

Instances

  • DoOnNext
  • DoOnError
  • DoOnCompleted

Each one returns a <-chan struct{} that closes once the Observable terminates.

Example

DoOnNext

<-rxgo.Just(1, 2, 3)().
	DoOnNext(func(i interface{}) {
		fmt.Println(i)
	})

Output:

1
2
3

DoOnError

<-rxgo.Just(1, 2, errors.New("foo"))().
	DoOnError(func(err error) {
		fmt.Println(err)
	})

Output:

foo

DoOnCompleted

<-rxgo.Just(1, 2, 3)().
	DoOnCompleted(func() {
		fmt.Println("done")
	})

Output:

done

Options