witoldsz
06/11/2017, 10:39 PMdiesieben07
06/11/2017, 10:44 PMdiesieben07
06/11/2017, 10:45 PMwitoldsz
06/11/2017, 10:46 PMdiesieben07
06/11/2017, 10:47 PMwitoldsz
06/11/2017, 10:49 PMtrace
is actually required there.diesieben07
06/11/2017, 10:50 PMdiesieben07
06/11/2017, 10:51 PMagomez
06/11/2017, 10:51 PMagomez
06/11/2017, 10:51 PMwitoldsz
06/11/2017, 10:51 PMinit
a mess.witoldsz
06/11/2017, 10:53 PMbind
methods, entire file is made of that init
and different event handlers.diesieben07
06/11/2017, 10:53 PMeventQueue
returns that takes a lambda with just the one parameter and adapts it. If you make it inline you won't have any performance cost either for the additional indirection.witoldsz
06/11/2017, 10:57 PMdiesieben07
06/11/2017, 10:57 PMdiesieben07
06/11/2017, 10:57 PMwitoldsz
06/11/2017, 10:58 PMdiesieben07
06/11/2017, 10:59 PMinline fun ThingThatEventQueueReturns.bind(name: String, handler: (String) -> Unit) = bind(name, { data, _ -> handler(data) })
diesieben07
06/11/2017, 10:59 PMwitoldsz
06/11/2017, 11:00 PMdiesieben07
06/11/2017, 11:00 PMwitoldsz
06/11/2017, 11:02 PMdiesieben07
06/11/2017, 11:03 PMwitoldsz
06/11/2017, 11:03 PMdiesieben07
06/11/2017, 11:04 PMdiesieben07
06/11/2017, 11:05 PMwitoldsz
06/11/2017, 11:05 PMagomez
06/11/2017, 11:06 PMwitoldsz
06/11/2017, 11:06 PMdiesieben07
06/11/2017, 11:06 PMfun foo(value: String) {
// value stays unused
}
// somewhere else:
foo("hello")
If you remove "value" from the method, you get a compile error, since the method call is no longer valid.diesieben07
06/11/2017, 11:07 PMagomez
06/11/2017, 11:08 PMwitoldsz
06/11/2017, 11:09 PMagomez
06/11/2017, 11:10 PMdiesieben07
06/11/2017, 11:10 PMfoo("hello")
in my example, the method reference in your example) in both cases.diesieben07
06/11/2017, 11:10 PMagomez
06/11/2017, 11:10 PMwitoldsz
06/11/2017, 11:13 PMdiesieben07
06/11/2017, 11:13 PMwitoldsz
06/11/2017, 11:13 PMwitoldsz
06/11/2017, 11:14 PMagomez
06/11/2017, 11:14 PMagomez
06/11/2017, 11:14 PMdiesieben07
06/11/2017, 11:15 PMdiesieben07
06/11/2017, 11:15 PM_
.witoldsz
06/11/2017, 11:18 PMinit
function with all the code inside lambdas? Or should I not use a super-nice feature of "this::" and just write by hand all the lambdas doing nothing but invoking the functions?diesieben07
06/11/2017, 11:19 PMdiesieben07
06/11/2017, 11:19 PMwitoldsz
06/11/2017, 11:20 PMagomez
06/11/2017, 11:20 PMdiesieben07
06/11/2017, 11:20 PMwitoldsz
06/11/2017, 11:21 PMwitoldsz
06/11/2017, 11:21 PMwitoldsz
06/11/2017, 11:22 PMsupress warningLooks like a kind of a compromise
witoldsz
06/11/2017, 11:23 PMwitoldsz
06/11/2017, 11:27 PM@Suppress("UNUSED_PARAMETER")
private fun onMarketRequested(data: String, trace: Trace) {…}
I hope one day Kotlin compiler will figure out the function as we see here is (indirectly) implementing an interface and such a workaround would not be necessary.