Skip to content

Instantly share code, notes, and snippets.

@abdolence
Created February 11, 2020 19:54
Show Gist options
  • Save abdolence/78efb065da23b1d9f45435e5c4d5ee22 to your computer and use it in GitHub Desktop.
Save abdolence/78efb065da23b1d9f45435e5c4d5ee22 to your computer and use it in GitHub Desktop.
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