ske
08/09/2018, 12:18 AMAndreas Sinz
08/09/2018, 9:00 AMske
08/09/2018, 9:15 PMske
08/09/2018, 9:16 PMclass Foo(): Bar by barImpl {
val barImpl = BarImpl()
}
, which would currently throw a "Unresolved reference" compiler error since "by" isn't allowed to check fields.ske
08/09/2018, 9:17 PMclass DiscordClient(val token: String) : EventDispatcher /* I'd like to do "by _state" here rather than have the below methods */{
internal val _state = ClientState()
// Implementation of EventDispatcher
// Not using "by" here because I'd like to keep it out of the primary constructor as a default parameter
override fun <T : DiscordEvent> listen(clazz: KClass<T>, predicate: (T) -> Boolean, removeAfterDispatch: Boolean, handler: suspend (T) -> Unit) = _state.listen(clazz, predicate, removeAfterDispatch, handler)
override suspend fun <T : DiscordEvent> dispatch(event: T, dispatchClass: KClass<T>) = _state.dispatch(event, dispatchClass)
ClientState contains the actual machinery for EventDispatcher but that's an internal class and I'd like to expose the APIs to DiscordClient without actually implementing it in DiscordClient (since it handles other things too and would quickly become huge)Andreas Sinz
08/09/2018, 9:19 PM_state
inside the class?ske
08/09/2018, 9:20 PMAndreas Sinz
08/09/2018, 9:37 PMcbruegg
08/10/2018, 1:39 PM