Skip to content

Commit

Permalink
Update GuiList.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkmar committed Mar 29, 2021
1 parent f7db1b5 commit ee9206d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package net.axay.fabrik.igui.observable

import net.axay.fabrik.core.task.coroutineTask

class GuiList<T>(val internalCollection: MutableList<T>) {
val listeners = HashSet<(List<T>) -> Unit>()

fun invokeListeners() = listeners.forEach { it.invoke(internalCollection) }

inline fun mutate(action: (MutableList<T>) -> Unit) {
action.invoke(internalCollection)
invokeListeners()
coroutineTask {
invokeListeners()
}
}
}

Expand Down

0 comments on commit ee9206d

Please sign in to comment.