Skip to content

Commit

Permalink
example (as test) of closure versus map
Browse files Browse the repository at this point in the history
  • Loading branch information
benjchristensen committed Feb 13, 2013
1 parent 70e9c08 commit c5a4c9c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/scala/rx/lang/scala/ScalaAdaptor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ class UnitTestSuite extends JUnitSuite {
verify(assertion, times(1)).received("1")
}

@Test def testClosureVersusMap() {
// using closure
Observable.toObservable("1", "2", "3")
.take(2)
.subscribe((callback: String) => {
println(callback)
})

// using Map of closures
Observable.toObservable("1", "2", "3")
.take(2)
.subscribe(Map(
"onNext" -> ((callback: String) => {
println(callback)
})))
}

@Test def testFilterWithToList() {
val numbers = Observable.toObservable[Int](1, 2, 3, 4, 5, 6, 7, 8, 9)
numbers.filter((x: Int) => 0 == (x % 2)).toList().subscribe(
Expand Down

0 comments on commit c5a4c9c

Please sign in to comment.