Skip to content

Instantly share code, notes, and snippets.

@davidbilge
Last active Jul 28, 2020
Embed
What would you like to do?
package de.cronos.mad.messages.backend;
import java.util.function.Supplier;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.DirectProcessor;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
public class RepeatTest {
private static class TestSubject {
public void logMonoValues(Supplier<Mono<String>> monoSupplier) {
Mono.defer(monoSupplier).repeat().subscribe(System.out::println);
}
}
@Test
public void repeatTest() {
DirectProcessor<String> testPublisher = DirectProcessor.create();
TestSubject testSubject = new TestSubject();
testSubject.logMonoValues(() -> Mono.from(testPublisher));
testPublisher.onNext("Hello");
testPublisher.onComplete();
testPublisher.onNext("World");
testPublisher.onComplete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment