Created
June 9, 2017 17:27
-
-
Save daniil-timofeev/b3108686d3dcfe865f01eb39e7eb1554 to your computer and use it in GitHub Desktop.
Is it possible to make no difference of order, when to call `onEvent'?
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 io.reactors.Events | |
object HighOrder extends App{ | |
var want1 = 0 | |
var want1Too = 0 | |
val have0 = new Events.Emitter[Int] | |
val factory = new Events.Emitter[Events[Int]] | |
val mux = factory.mux | |
val map = mux.map(x => x + 1) | |
map.onEvent(x => want1 = x) | |
factory.react(have0) | |
map.onEvent(x => want1Too = x) | |
have0.react(0) | |
assert(want1 == 1) | |
assert(want1Too == 1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment