Refactor
This commit is contained in:
parent
b0e05630ea
commit
8214c8dd97
|
@ -11,12 +11,6 @@ public class toLength implements Transformer<String, Integer> {
|
|||
|
||||
@Override
|
||||
public Observable<Integer> call(Observable<String> source) {
|
||||
|
||||
return source.map(new Func1<String, Integer>() {
|
||||
@Override
|
||||
public Integer call(String str) {
|
||||
return str.length();
|
||||
}
|
||||
});
|
||||
return source.map(String::length);
|
||||
}
|
||||
}
|
|
@ -96,14 +96,7 @@ public class RxJavaCustomOperatorUnitTest {
|
|||
|
||||
@Test
|
||||
public void whenUseFunctionTransformer_thenSuccess() {
|
||||
final Transformer<String, Integer> toLengthFn = source -> {
|
||||
return source.map(new Func1<String, Integer>() {
|
||||
@Override
|
||||
public Integer call(String str) {
|
||||
return str.length();
|
||||
}
|
||||
});
|
||||
};
|
||||
final Transformer<String, Integer> toLengthFn = source -> source.map(String::length);
|
||||
|
||||
final List<Integer> results = new ArrayList<Integer>();
|
||||
Observable.from(Arrays.asList("apple", "orange"))
|
||||
|
|
Loading…
Reference in New Issue