I played with the Java Flow offer operator, but after reading the documentation and completing my test, I do not understand.
Here is my test
@Test public void offer() throws InterruptedException { //Create Publisher for expected items Strings SubmissionPublisher<String> publisher = new SubmissionPublisher<>(); //Register Subscriber publisher.subscribe(new CustomSubscriber<>()); publisher.subscribe(new CustomSubscriber<>()); publisher.subscribe(new CustomSubscriber<>()); publisher.offer("item", (subscriber, value) -> false); Thread.sleep(500); }
The offer operator receives the element to be emitted and the BiPredicate function, and as I understand it, after reading the documentation, only if the predicate function is true, the element will be emitted.
After passing the test, the result:
Subscription done: Subscription done: Subscription done: Got : item --> onNext() callback Got : item --> onNext() callback Got : item --> onNext() callback
There is no change as a result if instead of false I return true.
Can someone explain this operator to me a little better please.
paul source share