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
.