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

com.yelstream.topp.furnace.reactive.integration.SimplePublisher 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 SimplePublisher implements Publisher {
    @Override
    public void subscribe(Subscriber subscriber) {
        subscriber.onSubscribe(new Subscription() {
            @Override
            public void request(long n) {
                new Thread(() -> {
                    try {
                        for (int i = 1; i <= 5; i++) {
                            subscriber.onNext(i);
                            Thread.sleep(1000); // Simulate delay between items
                        }
                        subscriber.onComplete();
                    } catch (InterruptedException e) {
                        subscriber.onError(e);
                    }
                }).start();
            }

            @Override
            public void cancel() {
                // Handle cancellation
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy