Skip to content

Commit

Permalink
Convert 'last' from non-blocking to blocking to match Rx.Net
Browse files Browse the repository at this point in the history
See ReactiveX/RxJava#57 (comment) for background.

NOTE: This is a breaking change thus we are bumping the version from 0.5.x to 0.6.x

Manual merge of branch 'last' of git://github.com/mairbek/RxJava into issue-57-last

Conflicts:
	rxjava-core/src/main/java/rx/Observable.java
  • Loading branch information
benjchristensen committed Mar 12, 2013
2 parents 8e2ad8f + 451ca91 commit 96f2628
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/test/groovy/rx/lang/groovy/ObservableTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import rx.Notification;
import rx.Observable;
import rx.Observer;
import rx.Subscription;
import rx.subscriptions.Subscriptions;
import rx.util.functions.Func1;

def class ObservableTests {
Expand Down Expand Up @@ -61,8 +62,12 @@ def class ObservableTests {

@Test
public void testLast() {
new TestFactory().getObservable().last().subscribe({ result -> a.received(result)});
verify(a, times(1)).received("hello_1");
assertEquals("three", Observable.toObservable("one", "two", "three").last())
}

@Test
public void testLastWithPredicate() {
assertEquals("two", Observable.toObservable("one", "two", "three").last({ x -> x.length() == 3}))
}

@Test
Expand Down Expand Up @@ -175,6 +180,12 @@ def class ObservableTests {
verify(a, times(0)).received(3);
}

@Test
public void testTakeLast() {
new TestFactory().getObservable().takeLast(1).subscribe({ result -> a.received(result)});
verify(a, times(1)).received("hello_1");
}

@Test
public void testTakeWhileViaGroovy() {
Observable.takeWhile(Observable.toObservable(1, 2, 3), { x -> x < 3}).subscribe({ result -> a.received(result)});
Expand Down Expand Up @@ -280,7 +291,7 @@ def class ObservableTests {
observer.onCompleted();
}
}).start();
return Observable.noOpSubscription();
return Subscriptions.empty();
}
}

Expand Down

0 comments on commit 96f2628

Please sign in to comment.