-
Notifications
You must be signed in to change notification settings - Fork 136
Scheduling Streams
johnmcclean-aol edited this page Jan 20, 2016
·
1 revision
simple-react 0.99.7 and above introduce Scheduling for LazyFutureStreams and SequenceM
Send one element of a Stream through every second.
LazyFutureStream.of(1,2,3,4)
.peek(System.out::println)
.schedule("* * * * * ?", ex)
This will print 1 2 3 4 With a new line per second.
We can connect to the output of this stream
HotStream connectable = LazyFutureStream.of(1,2,3,4)
.peek(System.out::println)
.schedule("* * * * * ?", ex);
And further process the connected Stream, in this case only processing one element per day via the debounce operator
LazyFutureStream.of(1,2,3,4)
.peek(System.out::println)
.schedule("* * * * * ?", ex)
.connect()
.debounce(1,TimeUnit.DAYS)
.peek(this::writeToDB)
.toList()
This time we will execute the Stream every second using a Fixed Rate delimiter
LazyFutureStream.of(1,2,3,4)
.peek(System.out::println)
.scheduleFixedRate(1000, ex)
.connect()
.debounce(1,TimeUnit.DAYS)
.peek(this::writeToDB)
.toList()
This time we will execute the Stream every second using a Fixed Delay delimiter
LazyFutureStream.of(1,2,3,4)
.peek(System.out::println)
.scheduleFixedDelay(2000, ex) //2 secs after previous element passes through
.connect()
.debounce(1,TimeUnit.DAYS)
.peek(this::writeToDB)
.toList()
oops - my bad