/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.gateway.test;

import java.util.ArrayList;
import java.util.Random;

import reactor.core.publisher.Flux;

/**
 * @author 田平 create 2019年11月19日下午2:10:02
 *
 */
public class ReactorTest2 {

	public static void main(String[] args) {
		Flux.generate(sink -> {
		    sink.next("Hello");
		    sink.complete();
		}).subscribe(System.out::println);
		 
		final Random random = new Random();
		Flux.generate(ArrayList::new, (list, sink) -> {
		    int value = random.nextInt(100);
		    list.add(value);
		    sink.next(value);
		    if (list.size() == 10) {
		        sink.complete();
		    }
		    return list;
		}).subscribe(System.out::println);
	}
}
