Skip to content

Commit

Permalink
flatmap: fixed typo example slice
Browse files Browse the repository at this point in the history
rewrite test to main example
  • Loading branch information
avelino committed Nov 3, 2018
1 parent 332f80d commit bfe1161
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions examples/flatmap/flatmap_slice.go
@@ -1,20 +1,16 @@
package main

import (
"testing"
"fmt"

"github.com/reactivex/rxgo/handlers"
"github.com/reactivex/rxgo/observable"
"github.com/reactivex/rxgo/observer"
)

func TestFlatMapExample(t *testing.T) {
// given
observerMock := observer.NewObserverMock()

// and
func main() {
primeSequence := observable.Just([]int{2, 3, 5, 7, 11, 13})

// when
<-primeSequence.
FlatMap(func(primes interface{}) observable.Observable {
return observable.Create(func(emitter *observer.Observer) {
Expand All @@ -25,8 +21,7 @@ func TestFlatMapExample(t *testing.T) {
})
}, 1).
Last().
Subscribe(observerMock.Capture())

// then
observerMock.AssertCalled(t, "OnNext", 13)
Subscribe(handlers.NextFunc(func(prime interface{}) {
fmt.Println("Prime -> ", prime)
}))
}

0 comments on commit bfe1161

Please sign in to comment.