Last active
August 29, 2015 14:20
-
-
Save ClausPolanka/5e7fb27d5d95f8bed730 to your computer and use it in GitHub Desktop.
Scala FlowDesign
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 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