Register an action to take upon a variety of Observable lifecycle events.
DoOnNext
DoOnError
DoOnCompleted
Each one returns a <-chan struct{}
that closes once the Observable terminates.
<-rxgo.Just(1, 2, 3)().
DoOnNext(func(i interface{}) {
fmt.Println(i)
})
Output:
1
2
3
<-rxgo.Just(1, 2, errors.New("foo"))().
DoOnError(func(err error) {
fmt.Println(err)
})
Output:
foo
<-rxgo.Just(1, 2, 3)().
DoOnCompleted(func() {
fmt.Println("done")
})
Output:
done