Skip to content

Commit

Permalink
Add Subscription.and(other) method.
Browse files Browse the repository at this point in the history
For Subscription composition.
  • Loading branch information
TomasMikula committed Mar 27, 2014
1 parent 64f10f4 commit ad97cc6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions reactfx/src/main/java/org/reactfx/Subscription.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@
public interface Subscription {
void unsubscribe();

/**
* Returns a new aggregate subscription whose {@link #unsubscribe()}
* method calls {@code unsubscribe()} on both this subscription and
* {@code other} subscription.
* @param other
*/
default Subscription and(Subscription other) {
return new BiSubscription(this, other);
}

static final Subscription EMPTY = () -> {};

/**
* Returns a new aggregate subscription whose {@link #unsubscribe()}
* method calls {@code unsubscribe()} on all arguments to this method.
* @param subs
*/
static Subscription multi(Subscription... subs) {
switch(subs.length) {
case 0: return EMPTY;
Expand Down

0 comments on commit ad97cc6

Please sign in to comment.