Skip to content

Commit 885de91

Browse files
Make Functions.from typesafe
1 parent bb45652 commit 885de91

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed

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)