Created
February 11, 2020 19:54
-
-
Save abdolence/78efb065da23b1d9f45435e5c4d5ee22 to your computer and use it in GitHub Desktop.
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 akka.actor.ActorSystem | |
import akka.stream._ | |
import akka.stream.scaladsl._ | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
def reactiveFizzbuzz( n: Int )( rules: Int => String ): Source[( Int, String ), _] = { | |
Source( | |
1 to n | |
).map(x => ( x, rules( x ) ) ) | |
} | |
implicit val system: ActorSystem = ActorSystem() | |
reactiveFizzbuzz( N )( basicFizzbuzzRules ) | |
.throttle( 10, 1.seconds ) | |
.runForeach( println ) | |
.andThen(_ => system.terminate ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment