withListener

fun <T, F : ValidatedField<T>> F.withListener(listener: Consumer<F>): F

Attaches a listener to the receiver field. This listener will be called any time the field is written to ("set"). accept, validateAndSet, setAndUpdate and so on will all call the listener.

Return

F the receiver is passed through

Author

fzzyhmstrs

Since

0.5.0

Parameters

F

the subtype of ValidatedField

listener

Consumer<F> called whenever the field changes. This should, generally speaking, not try to further modify the fields state unless there is a method to prevent infinite recursion.