Coroutines on overlay types #1063
-
|
I have an overlay type for a class in JavaScript which works as expected: @JSClass
public class ForkJoinPool implements JSObject {
public ForkJoinPool() {
}
public ForkJoinPool(int threads) {
}
public native <T> JSPromise<T> queueWork(Task<T> task);Needing to break my Java logic up to await for I thought this would be a good place to use a coroutine: @JSClass
public class ForkJoinPool implements JSObject {
public ForkJoinPool() {
}
public ForkJoinPool(int threads) {
}
@Async
public native <T> T queueWork(Task<T> task);
private <T> void queueWork(Task<T> task, AsyncCallback<T> callback) {
queueWorkAsync(task).then(result -> {
callback.complete(result);
return null;
}, error -> {
callback.error(new TaskException(error));
return null;
});
}
@JSMethod("queueWork")
private native <T> JSPromise<T> queueWorkAsync(Task<T> task);The Is using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
|
Beta Was this translation helpful? Give feedback.
@Asyncis not supported in exported methods/classes. Moreover, it's not recommended to ever use@Async(directly or indirectly, say, by callingThread.sleep) when you compile in "library" mode.