Skip to content

Commit f648f47

Browse files
committed
Merge pull request ReactiveX#3 from benjchristensen/static-core
Remove subscribe(Map<String, Object>) and cleanup Functions.from
2 parents 0237f1e + a26a86d commit f648f47

File tree

4 files changed

+10
-84
lines changed

4 files changed

+10
-84
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import rx.util.OnErrorNotImplementedException;
7878
import rx.util.Range;
7979
import rx.util.Timestamped;
80+
import rx.util.functions.Action;
8081
import rx.util.functions.Action0;
8182
import rx.util.functions.Action1;
8283
import rx.util.functions.Func0;
@@ -249,56 +250,6 @@ private Subscription protectivelyWrapAndSubscribe(Observer<T> o) {
249250
return subscription.wrap(subscribe(new SafeObserver<T>(subscription, o)));
250251
}
251252

252-
@SuppressWarnings({ "rawtypes", "unchecked" })
253-
public Subscription subscribe(final Map<String, Object> callbacks) {
254-
if (callbacks == null) {
255-
throw new RuntimeException("callbacks map can not be null");
256-
}
257-
Object _onNext = callbacks.get("onNext");
258-
if (_onNext == null) {
259-
throw new RuntimeException("'onNext' key must contain an implementation");
260-
}
261-
// lookup and memoize onNext
262-
final FuncN onNext = Functions.from(_onNext);
263-
264-
/**
265-
* Wrapping since raw functions provided by the user are being invoked.
266-
*
267-
* See https://github.com/Netflix/RxJava/issues/216 for discussion on "Guideline 6.4: Protect calls to user code from within an operator"
268-
*/
269-
return protectivelyWrapAndSubscribe(new Observer() {
270-
271-
@Override
272-
public void onCompleted() {
273-
Object onComplete = callbacks.get("onCompleted");
274-
if (onComplete != null) {
275-
Functions.from(onComplete).call();
276-
}
277-
}
278-
279-
@Override
280-
public void onError(Throwable e) {
281-
handleError(e);
282-
Object onError = callbacks.get("onError");
283-
if (onError != null) {
284-
Functions.from(onError).call(e);
285-
} else {
286-
throw new OnErrorNotImplementedException(e);
287-
}
288-
}
289-
290-
@Override
291-
public void onNext(Object args) {
292-
onNext.call(args);
293-
}
294-
295-
});
296-
}
297-
298-
public Subscription subscribe(final Map<String, Object> callbacks, Scheduler scheduler) {
299-
return subscribeOn(scheduler).subscribe(callbacks);
300-
}
301-
302253
public Subscription subscribe(final Action1<T> onNext) {
303254
if (onNext == null) {
304255
throw new IllegalArgumentException("onNext can not be null");
@@ -1086,13 +1037,13 @@ public static <R, T0, T1, T2, T3> Observable<R> zip(Observable<T0> w0, Observabl
10861037
* each time an event is received from one of the source observables, where the aggregation is defined by the given function.
10871038
* <p>
10881039
* <img width="640" src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/combineLatest.png">
1089-
*
1040+
*
10901041
* @param w0
1091-
* The first source observable.
1042+
* The first source observable.
10921043
* @param w1
1093-
* The second source observable.
1044+
* The second source observable.
10941045
* @param combineFunction
1095-
* The aggregation function used to combine the source observable values.
1046+
* The aggregation function used to combine the source observable values.
10961047
* @return An Observable that combines the source Observables with the given combine function
10971048
*/
10981049
public static <R, T0, T1> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Func2<T0, T1, R> combineFunction) {
@@ -1112,7 +1063,7 @@ public static <R, T0, T1, T2> Observable<R> combineLatest(Observable<T0> w0, Obs
11121063
public static <R, T0, T1, T2, T3> Observable<R> combineLatest(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0, T1, T2, T3, R> combineFunction) {
11131064
return create(OperationCombineLatest.combineLatest(w0, w1, w2, w3, combineFunction));
11141065
}
1115-
1066+
11161067
/**
11171068
* Creates an Observable which produces buffers of collected values.
11181069
*

rxjava-core/src/main/java/rx/subscriptions/Subscriptions.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import rx.Subscription;
2121
import rx.util.functions.Action0;
2222
import rx.util.functions.FuncN;
23+
import rx.util.functions.Function;
2324
import rx.util.functions.Functions;
2425

2526
/**
@@ -83,23 +84,6 @@ public static CompositeSubscription create(Subscription... subscriptions) {
8384
return new CompositeSubscription(subscriptions);
8485
}
8586

86-
/**
87-
* A {@link Subscription} implemented via an anonymous function (such as closures from other languages).
88-
*
89-
* @return {@link Subscription}
90-
*/
91-
public static Subscription create(final Object unsubscribe) {
92-
final FuncN<?> f = Functions.from(unsubscribe);
93-
return new Subscription() {
94-
95-
@Override
96-
public void unsubscribe() {
97-
f.call();
98-
}
99-
100-
};
101-
}
102-
10387
/**
10488
* A {@link Subscription} that does nothing when its unsubscribe method is called.
10589
*/

rxjava-core/src/main/java/rx/util/functions/Action.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* <p>
66
* Marker interface to allow instanceof checks.
77
*/
8-
public interface Action {
8+
public interface Action extends Function {
99

1010
}

rxjava-core/src/main/java/rx/util/functions/Functions.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
*/
1616
package rx.util.functions;
1717

18-
import java.util.Collection;
19-
import java.util.concurrent.ConcurrentHashMap;
20-
2118
public class Functions {
2219

2320
/**
@@ -26,17 +23,11 @@ public class Functions {
2623
* @param function
2724
*/
2825
@SuppressWarnings({ "rawtypes" })
29-
public static FuncN from(final Object function) {
26+
public static FuncN from(final Function function) {
3027
if (function == null) {
3128
throw new RuntimeException("function is null. Can't send arguments to null function.");
3229
}
33-
34-
/* check for typed Rx Function implementation first */
35-
if (function instanceof Function) {
36-
return fromFunction((Function) function);
37-
}
38-
// no support found
39-
throw new RuntimeException("Unsupported closure type: " + function.getClass().getSimpleName());
30+
return fromFunction(function);
4031
}
4132

4233
@SuppressWarnings({ "unchecked", "rawtypes" })

0 commit comments

Comments
 (0)