@ck
As below code shown, currently I have to use a wrapper to pass my Action delegate to an Java API:
public delegate void Action();
#if COOPER
public class ARunnable : Runnable {
private readonly Action mAction;
public ARunnable(Action action) {
mAction = action;
}
public void run() => mAction();
}
#endif
public class TestClass {
private Handler mHandler = new Handler();
public void test(Action action) {
mHandler.post(new ARunnable(action));
}
}
And I’ve known that Elements will compile “Action” to an Java interface:
public interface Action {
void Invoke();
}
Since java.lang.Runnable is a very basic and standard Java interface, I think it’s better to make the generated Action interface to extend it, like what Elements have done to a void lambda expression.
Or be more advanced, Elements can auto replace all void delegate types with java.lang.Runnable directly only for Java, then there’s no cross-platform overhead to communicate with standard Java API.