From 0635c73498da7ac88b13ff3b0da76307b8d50ebb Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Tue, 24 Sep 2024 20:28:37 +0200 Subject: [PATCH] singleton class Action replaced with singleton object Kotlin idiom. This brakes compatibility though. --- .../src/test/kotlin/BrowserPresenterTest.kt | 9 ++++----- xemantic-kotlin-swing-dsl-core/src/main/kotlin/Events.kt | 9 ++------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/demo/mvp-presenter/src/test/kotlin/BrowserPresenterTest.kt b/demo/mvp-presenter/src/test/kotlin/BrowserPresenterTest.kt index 69ffb43..7f26993 100644 --- a/demo/mvp-presenter/src/test/kotlin/BrowserPresenterTest.kt +++ b/demo/mvp-presenter/src/test/kotlin/BrowserPresenterTest.kt @@ -20,7 +20,6 @@ package com.xemantic.kotlin.swing.demo.mvp import com.xemantic.kotlin.swing.Action -import com.xemantic.kotlin.swing.action import com.xemantic.kotlin.swing.dsl.test.runSwingTest import io.kotest.matchers.should import io.kotest.matchers.shouldBe @@ -74,7 +73,7 @@ class BrowserPresenterTest { view.urlEdits.emit("https://example.com") // when - view.goActions.emit(action) + view.goActions.emit(Action) advanceUntilIdle() // then @@ -96,7 +95,7 @@ class BrowserPresenterTest { view.urlEdits.emit("https://example.com") // when - view.urlActions.emit(action) + view.urlActions.emit(Action) advanceUntilIdle() // then @@ -150,7 +149,7 @@ class BrowserPresenterTest { view.urlEdits.emit("https://example.com") // when - view.urlActions.emit(action) + view.urlActions.emit(Action) advanceUntilIdle() // then @@ -185,7 +184,7 @@ class BrowserPresenterTest { view.urlEdits.emit("foo") // when - view.urlActions.emit(action) + view.urlActions.emit(Action) advanceUntilIdle() // then diff --git a/xemantic-kotlin-swing-dsl-core/src/main/kotlin/Events.kt b/xemantic-kotlin-swing-dsl-core/src/main/kotlin/Events.kt index b8410db..36993b7 100644 --- a/xemantic-kotlin-swing-dsl-core/src/main/kotlin/Events.kt +++ b/xemantic-kotlin-swing-dsl-core/src/main/kotlin/Events.kt @@ -33,14 +33,9 @@ import javax.swing.text.JTextComponent * Represents and action, like click or touch event, without * any additional attributes. */ -class Action internal constructor() +object Action -/** - * An action instance. - */ -val action = Action() - -val Flow.asActions get() = map { action } +val Flow.asActions get() = map { Action } val Component.mouseEvents: Flow get() = callbackFlow { val listener = object : MouseListener {