Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Publisher 0..1 specialization #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ public interface Processor<T, R> extends Subscriber<T>, Publisher<R> {
While not mandated, it can be a good idea to cancel a `Processor`´s upstream `Subscription` when/if its last `Subscriber` cancels their `Subscription`,
to let the cancellation signal propagate upstream.

#### 5.MonoPublisher ([Code](https://github.com/reactive-streams/reactive-streams-jvm/blob/master/api/src/main/java/org/reactivestreams/MonoPublisher.java))

```java
public interface MonoPublisher<T> extends Publisher<T> {
}
````

| ID | Rule |
| ------------------------ | ------------------------------------------------------------------------------------------------------ |
| <a name="5.1">1</a> | A `MonoPublisher` represents a `Publisher` specialization and MUST obey its contract. |
| [:bulb:](#5.1 "5.1 explained") | *The intent of this rule is to establish that `MonoPublisher` can be used in place of any other `Publisher`.* |
| <a name="5.2">2</a> | The total number of `onNext`´s signalled by a `MonoPublisher` to a `Subscriber` MUST be less than or equal to one, regardless of the total number requested by that `Subscriber`´s `Subscription` at all times. |
| [:bulb:](#5.2 "5.2 explained") | *The intent of this rule is to make it clear that MonoPublishers cannot signal more than one element per `Subscriber`´s `Subscription`.* |

### Asynchronous vs Synchronous Processing ###

The Reactive Streams API prescribes that all processing of elements (`onNext`) or termination signals (`onError`, `onComplete`) MUST NOT *block* the `Publisher`. However, each of the `on*` handlers can process the events synchronously or asynchronously.
Expand Down
21 changes: 21 additions & 0 deletions api/src/main/java/org/reactivestreams/MonoPublisher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/************************************************************************
* Licensed under Public Domain (CC0) *
* *
* To the extent possible under law, the person who associated CC0 with *
* this code has waived all copyright and related or neighboring *
* rights to this code. *
* *
* You should have received a copy of the CC0 legalcode along with this *
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.*
************************************************************************/

package org.reactivestreams;

/**
* A {@link MonoPublisher} is a specialization of {@link Publisher} that emits at most one element.
*
* @param <T> the type of element signaled
*/
public interface MonoPublisher<T> extends Publisher<T> {

}