Skip to content

Commit

Permalink
singleton class Action replaced with singleton object Kotlin idiom. T…
Browse files Browse the repository at this point in the history
…his brakes compatibility though.
  • Loading branch information
morisil committed Sep 24, 2024
1 parent 744eadc commit 0635c73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
9 changes: 4 additions & 5 deletions demo/mvp-presenter/src/test/kotlin/BrowserPresenterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,7 +73,7 @@ class BrowserPresenterTest {
view.urlEdits.emit("https://example.com")

// when
view.goActions.emit(action)
view.goActions.emit(Action)
advanceUntilIdle()

// then
Expand All @@ -96,7 +95,7 @@ class BrowserPresenterTest {
view.urlEdits.emit("https://example.com")

// when
view.urlActions.emit(action)
view.urlActions.emit(Action)
advanceUntilIdle()

// then
Expand Down Expand Up @@ -150,7 +149,7 @@ class BrowserPresenterTest {
view.urlEdits.emit("https://example.com")

// when
view.urlActions.emit(action)
view.urlActions.emit(Action)
advanceUntilIdle()

// then
Expand Down Expand Up @@ -185,7 +184,7 @@ class BrowserPresenterTest {
view.urlEdits.emit("foo")

// when
view.urlActions.emit(action)
view.urlActions.emit(Action)
advanceUntilIdle()

// then
Expand Down
9 changes: 2 additions & 7 deletions xemantic-kotlin-swing-dsl-core/src/main/kotlin/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActionEvent>.asActions get() = map { action }
val Flow<ActionEvent>.asActions get() = map { Action }

val Component.mouseEvents: Flow<MouseEvent> get() = callbackFlow {
val listener = object : MouseListener {
Expand Down

0 comments on commit 0635c73

Please sign in to comment.