Skip to content

Commit

Permalink
Rename EventStream#suspendWhen to suspendedWhen.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasMikula committed Dec 27, 2015
1 parent b23685a commit 09e0023
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions reactfx/src/main/java/org/reactfx/EventStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ default SuspendableEventStream<T> suppressible() {
}

/**
* Shortcut for {@code suppressible().suspendWhen(condition)}.
* Shortcut for {@code suppressible().suspendedWhen(condition)}.
*/
default EventStream<T> suppressWhen(ObservableValue<Boolean> condition) {
return suppressible().suspendWhen(condition);
return suppressible().suspendedWhen(condition);
}

/**
Expand Down Expand Up @@ -633,10 +633,10 @@ default SuspendableEventStream<T> pausable() {
}

/**
* Shortcut for {@code pausable().suspendWhen(condition)}.
* Shortcut for {@code pausable().suspendedWhen(condition)}.
*/
default EventStream<T> pauseWhen(ObservableValue<Boolean> condition) {
return pausable().suspendWhen(condition);
return pausable().suspendedWhen(condition);
}

/**
Expand Down Expand Up @@ -664,10 +664,10 @@ default SuspendableEventStream<T> forgetful() {
}

/**
* Shortcut for {@code forgetful().suspendWhen(condition)}.
* Shortcut for {@code forgetful().suspendedWhen(condition)}.
*/
default EventStream<T> retainLatestWhen(ObservableValue<Boolean> condition) {
return forgetful().suspendWhen(condition);
return forgetful().suspendedWhen(condition);
}

/**
Expand Down Expand Up @@ -712,12 +712,12 @@ default SuspendableEventStream<T> reducible(BinaryOperator<T> reduction) {
}

/**
* Shortcut for {@code reducible(reduction).suspendWhen(condition)}.
* Shortcut for {@code reducible(reduction).suspendedWhen(condition)}.
*/
default EventStream<T> reduceWhen(
ObservableValue<Boolean> condition,
BinaryOperator<T> reduction) {
return reducible(reduction).suspendWhen(condition);
return reducible(reduction).suspendedWhen(condition);
}

/**
Expand Down Expand Up @@ -777,7 +777,7 @@ default <A> SuspendableEventStream<T> accumulative(
* <pre>
* {@code
* accumulative(initialTransformation, accumulation, size, head, tail)
* .suspendWhen(condition)}
* .suspendedWhen(condition)}
* </pre>
*/
default <A> EventStream<T> accumulateWhen(
Expand All @@ -788,7 +788,7 @@ default <A> EventStream<T> accumulateWhen(
Function<? super A, ? extends T> head,
Function<? super A, ? extends A> tail) {
return accumulative(initialTransformation, accumulation, size, head, tail)
.suspendWhen(condition);
.suspendedWhen(condition);
}

/**
Expand Down Expand Up @@ -841,7 +841,7 @@ default <A> SuspendableEventStream<T> accumulative(
* <pre>
* {@code
* accumulative(unit, accumulation, size, head, tail)
* .suspendWhen(condition)}
* .suspendedWhen(condition)}
* </pre>
*/
default <A> EventStream<T> accumulateWhen(
Expand All @@ -852,7 +852,7 @@ default <A> EventStream<T> accumulateWhen(
Function<? super A, ? extends T> head,
Function<? super A, ? extends A> tail) {
return accumulative(unit, accumulation, size, head, tail)
.suspendWhen(condition);
.suspendedWhen(condition);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions reactfx/src/main/java/org/reactfx/SuspendableEventStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public interface SuspendableEventStream<T> extends EventStream<T>, Suspendable {
* {@code condition} is {@code true} and emits normally when
* {@code condition} is {@code false}.
*/
default EventStream<T> suspendWhen(ObservableValue<Boolean> condition) {
return new SuspendWhenStream<>(this, condition);
default EventStream<T> suspendedWhen(ObservableValue<Boolean> condition) {
return new SuspendedWhenStream<>(this, condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import javafx.beans.value.ObservableValue;

class SuspendWhenStream<T> extends EventStreamBase<T> {
class SuspendedWhenStream<T> extends EventStreamBase<T> {
private final SuspendableEventStream<T> source;
private final ObservableValue<Boolean> condition;

private Guard suspensionGuard = null;

public SuspendWhenStream(
public SuspendedWhenStream(
SuspendableEventStream<T> source,
ObservableValue<Boolean> condition) {
this.source = source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import org.junit.Test;

public class SuspendWhenTest {
public class SuspendedWhenTest {

@Test
public void test() {
Property<Integer> p = new SimpleObjectProperty<>(0);
BooleanProperty suspended = new SimpleBooleanProperty(true);
List<Integer> emitted = new ArrayList<>();
SuspendableEventStream<Integer> pausable = EventStreams.valuesOf(p).pausable();
Subscription sub = pausable.suspendWhen(suspended).subscribe(emitted::add);
Subscription sub = pausable.suspendedWhen(suspended).subscribe(emitted::add);

// test that the stream started suspended
assertEquals(Arrays.asList(), emitted);
Expand Down

0 comments on commit 09e0023

Please sign in to comment.