Skip to content

Instantly share code, notes, and snippets.

@daniil-timofeev
Created June 9, 2017 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniil-timofeev/b3108686d3dcfe865f01eb39e7eb1554 to your computer and use it in GitHub Desktop.
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'?
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