Skip to content

Commit e3e148a

Browse files
author
jmhofer
committed
repaired rxjava-swing to work with new scheduler and observable api
1 parent bd10365 commit e3e148a

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

rxjava-contrib/rxjava-swing/src/main/java/rx/concurrency/SwingScheduler.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import rx.subscriptions.CompositeSubscription;
3939
import rx.subscriptions.Subscriptions;
4040
import rx.util.functions.Action0;
41-
import rx.util.functions.Func0;
4241
import rx.util.functions.Func2;
4342

4443
/**
@@ -187,14 +186,12 @@ public void testPeriodicScheduling() throws Exception {
187186
final CountDownLatch latch = new CountDownLatch(4);
188187

189188
final Action0 innerAction = mock(Action0.class);
190-
final Action0 unsubscribe = mock(Action0.class);
191-
final Func0<Subscription> action = new Func0<Subscription>() {
189+
final Action0 action = new Action0() {
192190
@Override
193-
public Subscription call() {
191+
public void call() {
194192
try {
195193
innerAction.call();
196194
assertTrue(SwingUtilities.isEventDispatchThread());
197-
return Subscriptions.create(unsubscribe);
198195
} finally {
199196
latch.countDown();
200197
}
@@ -210,7 +207,6 @@ public Subscription call() {
210207
sub.unsubscribe();
211208
waitForEmptyEventQueue();
212209
verify(innerAction, times(4)).call();
213-
verify(unsubscribe, times(4)).call();
214210
}
215211

216212
@Test

rxjava-contrib/rxjava-swing/src/main/java/rx/observables/SwingObservable.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import javax.swing.AbstractButton;
2727

2828
import rx.Observable;
29-
import static rx.Observable.filter;
3029
import rx.swing.sources.AbstractButtonSource;
3130
import rx.swing.sources.ComponentEventSource;
3231
import rx.swing.sources.KeyEventSource;
@@ -68,7 +67,7 @@ public static Observable<KeyEvent> fromKeyEvents(Component component) {
6867
* @return Observable of key events.
6968
*/
7069
public static Observable<KeyEvent> fromKeyEvents(Component component, final Set<Integer> keyCodes) {
71-
return filter(fromKeyEvents(component), new Func1<KeyEvent, Boolean>() {
70+
return fromKeyEvents(component).filter(new Func1<KeyEvent, Boolean>() {
7271
@Override
7372
public Boolean call(KeyEvent event) {
7473
return keyCodes.contains(event.getKeyCode());

rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/KeyEventSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void call() {
8585
* @see SwingObservable.fromKeyEvents(Component, Set)
8686
*/
8787
public static Observable<Set<Integer>> currentlyPressedKeysOf(Component component) {
88-
return Observable.<KeyEvent, Set<Integer>>scan(fromKeyEventsOf(component), new HashSet<Integer>(), new Func2<Set<Integer>, KeyEvent, Set<Integer>>() {
88+
return fromKeyEventsOf(component).<Set<Integer>>scan(new HashSet<Integer>(), new Func2<Set<Integer>, KeyEvent, Set<Integer>>() {
8989
@Override
9090
public Set<Integer> call(Set<Integer> pressedKeys, KeyEvent event) {
9191
Set<Integer> afterEvent = new HashSet<Integer>(pressedKeys);

0 commit comments

Comments
 (0)