Skip to content

Instantly share code, notes, and snippets.

@ClausPolanka
Last active August 29, 2015 14:20
Show Gist options
  • Save ClausPolanka/5e7fb27d5d95f8bed730 to your computer and use it in GitHub Desktop.
Save ClausPolanka/5e7fb27d5d95f8bed730 to your computer and use it in GitHub Desktop.
Scala FlowDesign
import scala.collection.mutable.MutableList
class A {
val onResult: MutableList[Function1[Int, Unit]] = MutableList.empty
def process(x: Int) = {
onResult.foreach(f => f(x))
}
}
class B {
def notifyResult(x: Int) = println("Result: " + x)
}
object FlowFesign {
def main(args: Array[String]): Unit = {
val a = new A
val b = new B
a.onResult += b.notifyResult
a.process(10)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment