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.
1515 */
1616package com .diffplug .common .swt .widgets ;
1717
18-
18+ import com . diffplug . common . rx . Rx ;
1919import 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 ;
2222import org .eclipse .swt .SWT ;
2323import org .eclipse .swt .graphics .Color ;
2424import 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