Created
May 7, 2017 13:32
-
-
Save razie/03b790e4440eb35e28930f3a493c33eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
object Sample2 { | |
val notificationStream : Stream[(String,String)] = Stream.empty | |
object db { | |
def findOrder(id:String) : Stream[{def accountId:String}] = Stream.empty | |
def findAccount(id:String) : Stream[{def email:String}] = Stream.empty | |
def updateAccount(id:Any) : Stream[Boolean] = Stream.empty | |
def updateOrder(id:Any) : Stream[Boolean] = Stream.empty | |
} | |
object email { | |
def send(id:String,n:String) : Stream[Boolean] = Stream.empty | |
} | |
notificationStream.flatMap { tuple=> | |
db.findOrder(tuple._1).map(o => (o, tuple._2)) | |
}.flatMap { tuple=> | |
db.updateOrder(tuple._1) | |
db.findAccount(tuple._1.accountId).map(o => (o, tuple._2)) | |
}.flatMap { tuple=> | |
db.updateAccount(tuple._1) | |
email.send(tuple._1.email, tuple._2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment