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

Switch Maybe and Single to use their Transformers in compose() #4651

Merged
merged 2 commits into from
Oct 1, 2016
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
5 changes: 2 additions & 3 deletions src/main/java/io/reactivex/Maybe.java
Original file line number Diff line number Diff line change
Expand Up @@ -1967,13 +1967,12 @@ public final <U> Maybe<U> cast(final Class<? extends U> clazz) {
* </dl>
*
* @param <R> the value type of the Maybe returned by the transformer function
* @param transformer
* implements the function that transforms the source Maybe
* @param transformer the transformer function, not null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I just borrowed from the Completable.compose() doc wording here

* @return a Maybe, transformed by the transformer function
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators">RxJava wiki: Implementing Your Own Operators</a>
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Maybe<R> compose(Function<? super Maybe<T>, ? extends MaybeSource<R>> transformer) {
public final <R> Maybe<R> compose(MaybeTransformer<T, R> transformer) {
return wrap(to(transformer));
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/reactivex/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -1467,13 +1467,12 @@ public final Single<T> hide() {
* </dl>
*
* @param <R> the value type of the single returned by the transformer function
* @param transformer
* implements the function that transforms the source Single
* @param transformer the transformer function, not null
* @return the source Single, transformed by the transformer function
* @see <a href="https://github.com/ReactiveX/RxJava/wiki/Implementing-Your-Own-Operators">RxJava wiki: Implementing Your Own Operators</a>
*/
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Single<R> compose(Function<? super Single<T>, ? extends SingleSource<R>> transformer) {
public final <R> Single<R> compose(SingleTransformer<T, R> transformer) {
return wrap(to(transformer));
}

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

package io.reactivex.internal.operators.single;

import static org.junit.Assert.*;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;

import org.junit.Test;

import io.reactivex.*;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.SingleSource;
import io.reactivex.SingleTransformer;
import io.reactivex.disposables.Disposables;
import io.reactivex.exceptions.TestException;
import io.reactivex.functions.*;
import io.reactivex.schedulers.Schedulers;
import org.junit.Test;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;

public class SingleMiscTest {
@Test
Expand Down Expand Up @@ -78,7 +83,7 @@ public void contains() {
public void compose() {

Single.just(1)
.compose(new Function<Single<Integer>, SingleSource<Object>>() {
.compose(new SingleTransformer<Integer, Object>() {
@Override
public SingleSource<Object> apply(Single<Integer> f) throws Exception {
return f.map(new Function<Integer, Object>() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/reactivex/maybe/MaybeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void toNull() {

@Test
public void compose() {
Maybe.just(1).compose(new Function<Maybe<Integer>, MaybeSource<Integer>>() {
Maybe.just(1).compose(new MaybeTransformer<Integer, Integer>() {
@Override
public MaybeSource<Integer> apply(Maybe<Integer> m) throws Exception {
return m.map(new Function<Integer, Integer>() {
Expand Down