Skip to content

Commit b4b5877

Browse files
authored
Prevent event dispatched from being rescheduled (#221)
1 parent 57b5027 commit b4b5877

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

src/main/kotlin/com/lambda/event/listener/SafeListener.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ class SafeListener<T : Event>(
125125
alwaysListen: Boolean = false,
126126
noinline function: SafeContext.(T) -> Unit = {}
127127
): SafeListener<T> {
128-
val listener = SafeListener<T>(priority, this, alwaysListen) { event ->
129-
runGameScheduled { function(event) }
130-
}
128+
val listener = SafeListener<T>(priority, this, alwaysListen) { function(it) }
131129

132130
EventFlow.syncListeners.subscribe(listener)
133131

@@ -170,9 +168,7 @@ class SafeListener<T : Event>(
170168
alwaysListen: Boolean = false,
171169
function: SafeContext.(T) -> Unit = {},
172170
): SafeListener<T> {
173-
val listener = SafeListener<T>(priority, this, alwaysListen) { event ->
174-
runGameScheduled { function(event) }
175-
}
171+
val listener = SafeListener<T>(priority, this, alwaysListen) { function(it) }
176172

177173
EventFlow.syncListeners.subscribe(kClass, listener)
178174

src/main/kotlin/com/lambda/event/listener/UnsafeListener.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ class UnsafeListener<T : Event>(
114114
alwaysListen: Boolean = false,
115115
noinline function: (T) -> Unit = {},
116116
): UnsafeListener<T> {
117-
val listener = UnsafeListener<T>(priority, this, alwaysListen) { event ->
118-
function(event)
119-
}
117+
val listener = UnsafeListener<T>(priority, this, alwaysListen) { function(it) }
120118

121119
EventFlow.syncListeners.subscribe(listener)
122120

0 commit comments

Comments
 (0)