Last active
October 25, 2020 13:29
-
-
Save latant/24bb9a5536d87fc7a99f534dfa702b5e to your computer and use it in GitHub Desktop.
Helper interfaces for Kotlin delegates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.reflect.KProperty | |
interface ValDelegate<C, P> { | |
operator fun getValue(thisRef: C, prop: KProperty<*>): P | |
} | |
interface ValDelegateProvider<C, P> { | |
operator fun provideDelegate(thisRef: C, prop: KProperty<*>): ValDelegate<C, P> | |
} | |
interface VarDelegate<C, P>: ValDelegate<C, P> { | |
operator fun setValue(thisRef: C, prop: KProperty<*>, value: P) | |
} | |
interface VarDelegateProvider<C, P> { | |
operator fun provideDelegate(thisRef: C, prop: KProperty<*>): VarDelegate<C, P> | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment