Skip to content

Release 0.2.1

Compare
Choose a tag to compare
@Maia-Everett Maia-Everett released this 19 May 17:23
· 29 commits to master since this release

GWT: Improve JsPromise compatibility with Java promises and exceptions.

  • JavaScript code that receives a JsPromise reference will only ever see then return native promises, regardless of the type of promises returned within Java then callbacks.
    • Example: JsPromise.create(...).then(result -> new GwtPromiseFactory().promise(...)) will return a native promise, even though a Java promise was created within the then callback.
  • Any Java exception thrown in Java code within a then callback will be seen as a native Error object (with the same message as the original exception) in JavaScript code that tries to inspect the promise rejection reason with a then reject callback. The same will happen if a JsPromise 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 a JavaScriptException.
  • If a native JavaScript then callback is wedged between a JsPromise being rejected to a Java exception and a Java JsPromise.then reject callback, and the JavaScript code passes the rejection Error 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.