Skip to content

Commit e57b470

Browse files
committed
Convert NoBorderBtn to Flow.
1 parent 6a4fa5c commit e57b470

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Diff for: durian-swt/src/main/java/com/diffplug/common/swt/widgets/NoBorderBtn.java

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 DiffPlug
2+
* Copyright (C) 2020-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,10 +15,10 @@
1515
*/
1616
package com.diffplug.common.swt.widgets;
1717

18-
18+
import com.diffplug.common.rx.Rx;
1919
import com.diffplug.common.swt.ControlWrapper;
20-
import io.reactivex.Observable;
21-
import io.reactivex.subjects.PublishSubject;
20+
import kotlinx.coroutines.flow.Flow;
21+
import kotlinx.coroutines.flow.MutableSharedFlow;
2222
import org.eclipse.swt.SWT;
2323
import org.eclipse.swt.graphics.Color;
2424
import org.eclipse.swt.graphics.Image;
@@ -38,7 +38,7 @@ public class NoBorderBtn extends ControlWrapper.AroundControl<Canvas> {
3838
private Image img = null;
3939
private Rectangle imgBounds;
4040
private boolean enabled = true;
41-
private PublishSubject<NoBorderBtn> selection = PublishSubject.create();
41+
private MutableSharedFlow<NoBorderBtn> selection = Rx.INSTANCE.createEmitFlow();
4242

4343
public NoBorderBtn(Composite parent) {
4444
super(new Canvas(parent, SWT.NONE));
@@ -61,17 +61,13 @@ public NoBorderBtn(Composite parent) {
6161
// send a selection event on each click (if we aren't disabled)
6262
wrapped.addListener(SWT.MouseDown, e -> {
6363
if (enabled) {
64-
selection.onNext(this);
64+
Rx.emit(selection, this);
6565
}
6666
});
67-
// send a "completed" event when we finish
68-
wrapped.addListener(SWT.Dispose, e -> {
69-
selection.onComplete();
70-
});
7167
}
7268

7369
/** Returns an Observable which responds to clicks. */
74-
public Observable<NoBorderBtn> clicked() {
70+
public Flow<NoBorderBtn> clicked() {
7571
return selection;
7672
}
7773

0 commit comments

Comments
 (0)