Release 0.2.1
GWT: Improve JsPromise
compatibility with Java promises and exceptions.
- JavaScript code that receives a
JsPromise
reference will only ever seethen
return native promises, regardless of the type of promises returned within Javathen
callbacks.- Example:
JsPromise.create(...).then(result -> new GwtPromiseFactory().promise(...))
will return a native promise, even though a Java promise was created within thethen
callback.
- Example:
- Any Java exception thrown in Java code within a
then
callback will be seen as a nativeError
object (with the same message as the original exception) in JavaScript code that tries to inspect the promise rejection reason with athen
reject callback. The same will happen if aJsPromise
is rejected to a Java exception in Java code. - If a native promise is rejected in JavaScript code, a Java
JsPromise.then
callback will see the error as aJavaScriptException
. - If a native JavaScript
then
callback is wedged between aJsPromise
being rejected to a Java exception and a JavaJsPromise.then
reject callback, and the JavaScript code passes the rejectionError
object unchanged, then the Java reject callback will see the original Java exception, also unchanged.
The latter two items are patterned after existing synchronous GWT behavior, where any error thrown in JavaScript code that unwinds to Java code is seen as a JavaScriptException
, and a Java exception passes through JavaScript code unchanged during stack unwinding.