Adding example of cancelled operator (#29749)

Co-authored-by: Arnout Engelen <github@bzzt.net>
Co-authored-by: Renato Cavalcanti <renato@cavalcanti.be>
This commit is contained in:
Muskan Gupta 2020-10-20 17:13:26 +05:30 committed by GitHub
parent 9c200e3a04
commit 432d94d5a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2020 Lightbend Inc. <https://www.lightbend.com>
*/
package docs.stream.operators.sink
import akka.NotUsed
import akka.actor.ActorSystem
import akka.stream.scaladsl.{ Sink, Source }
import scala.concurrent.ExecutionContextExecutor
object Cancelled {
implicit val system: ActorSystem = ???
implicit val ec: ExecutionContextExecutor = system.dispatcher
def cancelledExample(): NotUsed = {
//#cancelled
val source = Source(1 to 5)
source.runWith(Sink.cancelled)
//#cancelled
}
}