'Listener in Kotlin

I am new to Kotlin. I received a value in my class method via listener and now I want to push that value to whoever is calling my method. How do I add a listener in my class, so that the caller can register to the listener to get the value instead of my method returning the value.

//function

public fun GetValue(feature:String): Boolean {

    var Value = true

    val Listener = FeatureFlagListener {
            Value = //updated value
                    //How do I push the Value from here to the caller
        }
            
    RegisterFeatureFlagListener(feature,Listener)
    return Value

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source