Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
SerVB committed Mar 22, 2022
1 parent f0ab6e1 commit 268cf3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,8 @@ class WindowSizeController(private val stateMachine: ClientStateMachine) {
stateMachine.fire(ClientAction.WindowResize)
}

private var listening = false

fun addListenerIfNeeded() {
if (!listening) {
window.addEventListener(RESIZE_EVENT_TYPE, ::handleResizeEvent)
listening = true
}
init {
window.addEventListener(RESIZE_EVENT_TYPE, ::handleResizeEvent)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ sealed class ClientState {
private val onHandshakeFinish: () -> Unit = {},
) : ClientState() {

init {
windowSizeController.addListenerIfNeeded()
}

override fun consume(action: ClientAction) = when (action) {
is ClientAction.WebSocket.Open -> {
OnScreenMessenger.showText("Connection is opened", "Sending handshake...", canReload = false)
Expand Down

0 comments on commit 268cf3f

Please sign in to comment.