Skip to content

Releases: Maia-Everett/jpromises

Release 0.3.2

08 Aug 09:02
Compare
Choose a tag to compare

Small bugfix release affecting a breaking bug in the GWT version only. Same as 0.3.1, but with Javadoc added.

jpromises:

  • No changes since 0.3.0.

jpromises-gwt:

  • Fixed definition of then in JsPromise that broke error propagation, causing a rejected JS promise to return the wrong error and lose the original one.

Release 0.3.1

08 Aug 08:11
Compare
Choose a tag to compare

Small bugfix release affecting a breaking bug in the GWT version only.

jpromises:

  • No changes since 0.3.0.

jpromises-gwt:

  • Fixed definition of then in JsPromise that broke error propagation, causing a rejected JS promise to return the wrong error and lose the original one.

Release 0.3.0

27 Jul 06:32
Compare
Choose a tag to compare

API breaking release. Binary compatibility should be preserved, unless you relied on the one removed method.

  • Removed PromiseFactory.ofNull. There isn't really a good use case for it when PromiseFactory.resolve(null) exists and returning null from then callbacks is usually sufficient.
  • Thenable.then is now required not to throw checked exceptions.
  • All uses of then callbacks are now declared with super for the promise's resolved value. For example, the single-argument then now accepts a ResolveCallback<? super V, ? extends R>.
  • Added Promise.thenRun, which ignores the promise's resolved value.
  • Added then, thenCompose, thenApply, thenAccept and thenRun methods to JsPromise, in both their single-argument and two-argument forms.

Release 0.2.2

27 Jun 17:26
Compare
Choose a tag to compare

Minor improvements.

  • Removed excessive synchronization from Promise. In particular, it no longer executes alien code (then callbacks) within its synchronized blocks, as this is fragile and deadlock-prone (Effective Java item 67). Locks are now only held strictly as necessary.
  • Reject callbacks are now declared as throws Throwable rather than throws Exception. This makes the "execute cleanup code and rethrow" idiom more natural to express in thenApply and thenAccept:
promise.thenApply(result -> { ... }, exception -> {
    loadingIndicator.hide();
    submitButton.enable();
    throw exception;
});

Release 0.2.1

19 May 17:23
Compare
Choose a tag to compare

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.

Release 0.2.0

19 May 17:10
Compare
Choose a tag to compare

API breaking release.

  • Moved Promise and PromiseFactory to root package org.lucidfox.jpromises to better present them as the core classes of the library.
  • Merged Resolver and Rejector into one interface, named Resolver.
    • There was really no reason to have two interfaces, other than the fact that JavaScript promises use two functions. Since Resolver is already not a functional interface (it has deferResolve), it makes sense to merge everything into it.
  • Convenience then overloads renamed to thenAccept and thenApply to make IDEs play nicer with lambda type inference, much like CompletableFuture does.
  • onException and onExceptionApply now restrict the type of the return value to the value type of the promise, and pass it unchanged if the promise was resolved rather than rejected.
  • Added convenience methods to PromiseFactory: promiseAsync, supplyAsync and runAsync, which use the specified executor to resolve a promise off the main thread without having to manually write glue code for it.
  • Added Resolver.getPromise, which provides access to the promise instance within the promise handler while it is being resolved. Corner case, but occasionally useful for tracking promise identity in collections.
  • GWT: JsPromise now uses JsResolver and JsPromiseHandler, so that getPromise can return the correct type for its construction.
  • Added AndroidPromiseFactory.

Release 0.1

02 Apr 13:53
Compare
Choose a tag to compare

Initial release.