All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yelstream.topp.furnace.reactive.integration.StreamPublisherExample Maven / Gradle / Ivy

Go to download

Topp Furnace Reactive Integration provides interactions between selected reactive frameworks.

The newest version!
package com.yelstream.topp.furnace.reactive.integration;

import java.util.concurrent.Flow.*;

public class StreamPublisherExample {
    public static void main(String[] args) {
        java.util.stream.Stream stream = java.util.stream.Stream.of(1, 2, 3, 4, 5);

        Publisher publisher = new StreamPublisher<>(stream);

        publisher.subscribe(new Subscriber() {
            @Override
            public void onSubscribe(Subscription subscription) {
                subscription.request(5); // Request all items
            }

            @Override
            public void onNext(Integer item) {
                System.out.println("Received item: " + item);
            }

            @Override
            public void onError(Throwable throwable) {
                System.err.println("Error: " + throwable.getMessage());
            }

            @Override
            public void onComplete() {
                System.out.println("Completed");
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy