Created
July 9, 2015 22:39
-
-
Save groz/485c4dfe6c87a80c3cba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import info.fotm.crawler.ObservableStream | |
val sink = new ObservableStream[Int] { | |
def put(x: Int) = super.publish(x) | |
} | |
val othersink = new ObservableStream[Int] { | |
def put(x: Int) = super.publish(x) | |
} | |
for (x <- sink) { | |
println(s"Sink: $x") | |
} | |
for (y <- othersink) { | |
println(s"Other sink: $y") | |
} | |
val combinedSink = for { | |
x <- sink | |
if x % 2 == 0 | |
y <- othersink | |
} yield (x, y) | |
for (xy <- combinedSink) { | |
println(s"Combined sink: $xy") | |
} | |
sink.put(1) // Sink: 1 | |
sink.put(2) // Sink: 2 | |
sink.put(3) // Sink: 3 | |
othersink.put(10) // Other sink: 30, Combined sink: (2, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment