Skip to content

Instantly share code, notes, and snippets.

@razie
Created May 7, 2017 13:32
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 razie/03b790e4440eb35e28930f3a493c33eb to your computer and use it in GitHub Desktop.
Save razie/03b790e4440eb35e28930f3a493c33eb to your computer and use it in GitHub Desktop.
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