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

from(T) -> just(T) #1576

Merged
merged 1 commit into from
Aug 14, 2014
Merged
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
370 changes: 330 additions & 40 deletions rxjava-core/src/main/java/rx/Observable.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package rx.internal.operators;

import static rx.Observable.concat;
import static rx.Observable.from;
import static rx.Observable.just;
import static rx.Observable.zip;
import rx.Observable;
import rx.functions.Func1;
Expand All @@ -43,7 +43,7 @@ public Object call(T t1) {
return t1;
}

}), from(LOCAL_ONCOMPLETED));
}), just(LOCAL_ONCOMPLETED));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions rxjava-core/src/test/java/rx/CombineLatestTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class CombineLatestTests {
*/
@Test
public void testCovarianceOfCombineLatest() {
Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie());
Observable<CoolRating> ratings = Observable.from(new CoolRating());
Observable<HorrorMovie> horrors = Observable.just(new HorrorMovie());
Observable<CoolRating> ratings = Observable.just(new CoolRating());

Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlocking().forEach(action);
Expand Down
36 changes: 18 additions & 18 deletions rxjava-core/src/test/java/rx/ConcatTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class ConcatTests {

@Test
public void testConcatSimple() {
Observable<String> o1 = Observable.from("one", "two");
Observable<String> o2 = Observable.from("three", "four");
Observable<String> o1 = Observable.just("one", "two");
Observable<String> o2 = Observable.just("three", "four");

List<String> values = Observable.concat(o1, o2).toList().toBlocking().single();

Expand All @@ -44,11 +44,11 @@ public void testConcatSimple() {

@Test
public void testConcatWithObservableOfObservable() {
Observable<String> o1 = Observable.from("one", "two");
Observable<String> o2 = Observable.from("three", "four");
Observable<String> o3 = Observable.from("five", "six");
Observable<String> o1 = Observable.just("one", "two");
Observable<String> o2 = Observable.just("three", "four");
Observable<String> o3 = Observable.just("five", "six");

Observable<Observable<String>> os = Observable.from(o1, o2, o3);
Observable<Observable<String>> os = Observable.just(o1, o2, o3);

List<String> values = Observable.concat(os).toList().toBlocking().single();

Expand All @@ -62,9 +62,9 @@ public void testConcatWithObservableOfObservable() {

@Test
public void testConcatWithIterableOfObservable() {
Observable<String> o1 = Observable.from("one", "two");
Observable<String> o2 = Observable.from("three", "four");
Observable<String> o3 = Observable.from("five", "six");
Observable<String> o1 = Observable.just("one", "two");
Observable<String> o2 = Observable.just("three", "four");
Observable<String> o3 = Observable.just("five", "six");

@SuppressWarnings("unchecked")
Iterable<Observable<String>> is = Arrays.asList(o1, o2, o3);
Expand All @@ -86,10 +86,10 @@ public void testConcatCovariance() {
Media media = new Media();
HorrorMovie horrorMovie2 = new HorrorMovie();

Observable<Media> o1 = Observable.<Media> from(horrorMovie1, movie);
Observable<Media> o2 = Observable.from(media, horrorMovie2);
Observable<Media> o1 = Observable.<Media> just(horrorMovie1, movie);
Observable<Media> o2 = Observable.just(media, horrorMovie2);

Observable<Observable<Media>> os = Observable.from(o1, o2);
Observable<Observable<Media>> os = Observable.just(o1, o2);

List<Media> values = Observable.concat(os).toList().toBlocking().single();

Expand All @@ -108,10 +108,10 @@ public void testConcatCovariance2() {
Media media2 = new Media();
HorrorMovie horrorMovie2 = new HorrorMovie();

Observable<Media> o1 = Observable.from(horrorMovie1, movie, media1);
Observable<Media> o2 = Observable.from(media2, horrorMovie2);
Observable<Media> o1 = Observable.just(horrorMovie1, movie, media1);
Observable<Media> o2 = Observable.just(media2, horrorMovie2);

Observable<Observable<Media>> os = Observable.from(o1, o2);
Observable<Observable<Media>> os = Observable.just(o1, o2);

List<Media> values = Observable.concat(os).toList().toBlocking().single();

Expand All @@ -130,8 +130,8 @@ public void testConcatCovariance3() {
Media media = new Media();
HorrorMovie horrorMovie2 = new HorrorMovie();

Observable<Movie> o1 = Observable.from(horrorMovie1, movie);
Observable<Media> o2 = Observable.from(media, horrorMovie2);
Observable<Movie> o1 = Observable.just(horrorMovie1, movie);
Observable<Media> o2 = Observable.just(media, horrorMovie2);

List<Media> values = Observable.concat(o1, o2).toList().toBlocking().single();

Expand Down Expand Up @@ -160,7 +160,7 @@ public void call(Subscriber<? super Movie> o) {
}
});

Observable<Media> o2 = Observable.from(media, horrorMovie2);
Observable<Media> o2 = Observable.just(media, horrorMovie2);

List<Media> values = Observable.concat(o1, o2).toList().toBlocking().single();

Expand Down
6 changes: 3 additions & 3 deletions rxjava-core/src/test/java/rx/CovarianceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class CovarianceTest {
*/
@Test
public void testCovarianceOfFrom() {
Observable.<Movie> from(new HorrorMovie());
Observable.<Movie> just(new HorrorMovie());
Observable.<Movie> from(new ArrayList<HorrorMovie>());
// Observable.<HorrorMovie>from(new Movie()); // may not compile
}
Expand All @@ -49,11 +49,11 @@ public Integer call(Media t1, Media t2) {
};

// this one would work without the covariance generics
Observable<Media> o = Observable.from(new Movie(), new TVSeason(), new Album());
Observable<Media> o = Observable.just(new Movie(), new TVSeason(), new Album());
o.toSortedList(SORT_FUNCTION);

// this one would NOT work without the covariance generics
Observable<Movie> o2 = Observable.from(new Movie(), new ActionMovie(), new HorrorMovie());
Observable<Movie> o2 = Observable.just(new Movie(), new ActionMovie(), new HorrorMovie());
o2.toSortedList(SORT_FUNCTION);
}

Expand Down
20 changes: 10 additions & 10 deletions rxjava-core/src/test/java/rx/MergeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ public class MergeTests {
*/
@Test
public void testCovarianceOfMerge() {
Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie());
Observable<HorrorMovie> horrors = Observable.just(new HorrorMovie());
Observable<Observable<HorrorMovie>> metaHorrors = Observable.just(horrors);
Observable.<Media> merge(metaHorrors);
}

@Test
public void testMergeCovariance() {
Observable<Media> o1 = Observable.<Media> from(new HorrorMovie(), new Movie());
Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie());
Observable<Media> o1 = Observable.<Media> just(new HorrorMovie(), new Movie());
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());

Observable<Observable<Media>> os = Observable.from(o1, o2);
Observable<Observable<Media>> os = Observable.just(o1, o2);

List<Media> values = Observable.merge(os).toList().toBlocking().single();

Expand All @@ -53,10 +53,10 @@ public void testMergeCovariance() {

@Test
public void testMergeCovariance2() {
Observable<Media> o1 = Observable.from(new HorrorMovie(), new Movie(), new Media());
Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie());
Observable<Media> o1 = Observable.just(new HorrorMovie(), new Movie(), new Media());
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());

Observable<Observable<Media>> os = Observable.from(o1, o2);
Observable<Observable<Media>> os = Observable.just(o1, o2);

List<Media> values = Observable.merge(os).toList().toBlocking().single();

Expand All @@ -65,8 +65,8 @@ public void testMergeCovariance2() {

@Test
public void testMergeCovariance3() {
Observable<Movie> o1 = Observable.from(new HorrorMovie(), new Movie());
Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie());
Observable<Movie> o1 = Observable.just(new HorrorMovie(), new Movie());
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());

List<Media> values = Observable.merge(o1, o2).toList().toBlocking().single();

Expand All @@ -90,7 +90,7 @@ public void call(Subscriber<? super Movie> o) {
}
});

Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie());
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());

List<Media> values = Observable.merge(o1, o2).toList().toBlocking().single();

Expand Down
4 changes: 2 additions & 2 deletions rxjava-core/src/test/java/rx/ObservableDoOnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ObservableDoOnTest {
@Test
public void testDoOnEach() {
final AtomicReference<String> r = new AtomicReference<String>();
String output = Observable.from("one").doOnNext(new Action1<String>() {
String output = Observable.just("one").doOnNext(new Action1<String>() {

@Override
public void call(String v) {
Expand Down Expand Up @@ -69,7 +69,7 @@ public void call(Throwable v) {
@Test
public void testDoOnCompleted() {
final AtomicBoolean r = new AtomicBoolean();
String output = Observable.from("one").doOnCompleted(new Action0() {
String output = Observable.just("one").doOnCompleted(new Action0() {

@Override
public void call() {
Expand Down
Loading