Skip to content

Commit

Permalink
add remove for state-change-listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerbrandl committed Jun 4, 2024
1 parent c4ffdc1 commit 8c2902a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/org/kalasim/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ open class State<T>(
/** Register a change listener. Will be invoked on every value change of the state. */
fun onChange(function: StateChangeListener<T>) = changeListeners.add(function)

fun removeChangeListener(function: StateChangeListener<T>) = changeListeners.remove(function)

override val snapshot
get() = StateSnapshot(env.now, name, value.toString(), waiters.q.map { it.component.name })
}

0 comments on commit 8c2902a

Please sign in to comment.