Hello,
Is it possible to have a push stream of push streams? PushStream<PushStream<T>> And if so how can I flatten it to a PushStream<T>? The example I am trying looks something like this: private static PushStreamProvider streams = new PushStreamProvider(); public static void main(String[] args) throws InterruptedException { // Emit 1,2,3 asynchronously and close PushStream<Integer> xs = streams.createStream(list(1 ,2, 3)); // Emit un-connected streams each of which once connected will emit a number every X seconds PushStream<PushStream<Integer>> yss = xs.map(x -> streams.createStream(time(x)).map(ignore -> x)); // Flatten all time events into one stream PushStream<Integer> zs = yss.flatMap(ts -> ts); // This should connect all 3 timer streams and print the output for 15 sec // Instead only the first timer stream is connected zs.forEach(i -> print(i)); Thread.sleep(SECONDS.toMillis(15)); zs.close(); } // Starts a thread that emits an event every pause seconds public static PushEventSource<Integer> time(int pause) { ... } // Starts a thread that emits the items on the list and closes the stream public static <T> PushEventSource<T> list(T... list) {...} Regards ----------------------------------- Todor Boev OSGi Platform Software AG
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev