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

com.yelstream.topp.furnace.reactive.integration.IterablePublisherExample 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.Arrays;
import java.util.concurrent.Flow.*;

public class IterablePublisherExample {
    public static void main(String[] args) {
        Iterable iterable = Arrays.asList(1, 2, 3, 4, 5);

        Publisher publisher = new IterablePublisher<>(iterable);

        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