Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.