Releases: Maia-Everett/jpromises
Releases · Maia-Everett/jpromises
Release 0.3.2
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
inJsPromise
that broke error propagation, causing a rejected JS promise to return the wrong error and lose the original one.
Release 0.3.1
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
inJsPromise
that broke error propagation, causing a rejected JS promise to return the wrong error and lose the original one.
Release 0.3.0
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 whenPromiseFactory.resolve(null)
exists and returningnull
fromthen
callbacks is usually sufficient. Thenable.then
is now required not to throw checked exceptions.- All uses of
then
callbacks are now declared withsuper
for the promise's resolved value. For example, the single-argumentthen
now accepts aResolveCallback<? super V, ? extends R>
. - Added
Promise.thenRun
, which ignores the promise's resolved value. - Added
then
,thenCompose
,thenApply
,thenAccept
andthenRun
methods toJsPromise
, in both their single-argument and two-argument forms.
Release 0.2.2
Minor improvements.
- Removed excessive synchronization from
Promise
. In particular, it no longer executes alien code (then
callbacks) within itssynchronized
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 thanthrows Exception
. This makes the "execute cleanup code and rethrow" idiom more natural to express inthenApply
andthenAccept
:
promise.thenApply(result -> { ... }, exception -> {
loadingIndicator.hide();
submitButton.enable();
throw exception;
});
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.
Release 0.2.0
API breaking release.
- Moved
Promise
andPromiseFactory
to root packageorg.lucidfox.jpromises
to better present them as the core classes of the library. - Merged
Resolver
andRejector
into one interface, namedResolver
.- 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 hasdeferResolve
), it makes sense to merge everything into it.
- There was really no reason to have two interfaces, other than the fact that JavaScript promises use two functions. Since
- Convenience
then
overloads renamed tothenAccept
andthenApply
to make IDEs play nicer with lambda type inference, much likeCompletableFuture
does. onException
andonExceptionApply
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
andrunAsync
, 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 usesJsResolver
andJsPromiseHandler
, so thatgetPromise
can return the correct type for its construction. - Added
AndroidPromiseFactory
.
Release 0.1
Initial release.