Streams are usually pull-based. At the example below, foreach()
(last method in the pipeline) starts the pipeline execution and pulls data from the source list.
List<Integer> lst = Arrays.asList(1,2,3);
lst.stream()
.filter(k -> k > 1)
.forEach(k->
System.out.println(k)
);
On the other hand, Observable
s (and Publisher
s) are push-based. They start execution by themselves and push information into their subscribers. So subscribers must implement some interface which contains appropriate method which accepts the next value. Typically this method is named "update", "onNext", "post", "send", etc.
Push-based approach can cause troubles, when publisher (producer) works faster than subscriber (consumer). In such cases, reactive streams
can help, where consumer may control the speed of producer, thus changing the transfer policy to pull-based.