- package com.dahua88.monixLearn
-
- import monix.eval._
-
- import scala.concurrent.duration.DurationInt
- import monix.reactive._
- import monix.execution.Scheduler.Implicits.global
-
- import java.lang.Thread.sleep
- import scala.util.Random
-
- // Needed below
- import scala.concurrent.duration._
-
- object MonixLearn1 {
- def main(args: Array[String]): Unit = {
-
-
- // Nothing happens here, as observable is lazily
- // evaluated only when the subscription happens!
- val tick = {
- Observable
- .fromIterable[Int](11 to 220 toIterable)
- // .interval(1.second)
- // common filtering and mapping
- .map {
- x =>
- println(s"filter ${x}")
- sleep(Random.nextInt(3000))
- x + 1000
- }
- .map{x =>
- printl