Skip to content

Commit

Permalink
Added Property update method
Browse files Browse the repository at this point in the history
  • Loading branch information
byerlyb20 committed Mar 26, 2024
1 parent 1c4515f commit 772a6a2
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class Property<T>(startValue: T) : ImmediateWritable<T>, ReadWriteProperty<Any?,
this.value = value
}

infix fun update(action: T.() -> Unit) {
action(value)
listeners.toList().forEach { it() }
}

override suspend fun awaitRaw(): T = value

override fun addListener(listener: () -> Unit): () -> Unit {
Expand Down

0 comments on commit 772a6a2

Please sign in to comment.