Date: 2019-10-03
- Minor code simplication
- cljdoc integration
Date: 2019-10-01
Relevant changes (many breaking changes that affects functions and macros that are not heavily used):
-
Remove the ability to create a promise using factory function with
promise
constructor (now this responsability is delegated to thecreate
function, see below). -
Remove the old
do*
macro. -
Add
do!
macro (that should have been thedo*
from the begining). It treats each individual expression as a expression that evaluates to promise and executes serially awaiting each expression. Returns a promise resolved to the result of the last expression, ignoring all intermediate results.
(require '[promesa.core :as p])
(p/do! (expr1)
(expr2)
(expr3))
;; That is roughtly equivalent to:
(p/alet [_ (expr1)
_ (expr2)]
(expr3))
-
Refactor execution strategy: before this change all the chained callback functions (with
map
,then
, etc..) they were running in a separated (async) microtask (forkJoinPool on the jvm). Now promesa does not makes any asumption about this and delegate this decision to the user of this library.What are the implications for the end user?: In terms of api changes, nothing; all the public api is the same. The main change consists in the execution semantics. Now all the chained functions (by default) will be executed in the calling/resolver thread instead of a new task for each step. This will leverage a better performance and less latency on all chain execution.
Also, promesa exposes additional arities to
map
,then
,bind
andmapcat
for provide a custom executor service if you need it.The
promise
anddeferred
(read more below) promise constructors also accepts a new arity for specify the executor where evaluate the factory function or promise resolution (by default is in the calling thread).The execution semantic changes are only relevant on the JVM, on cljs nothing is changed.
-
Rewrite
finally
function: now receives a promise and a function (potentiall side-effectful) that will receive resolved value as first argument if the promise is resolved or exception as second argument if promise is rejected. The return value is ignored. It always returns the same promise (like identity function). -
Remove 0 arity from
promise
function (now is delegated todeferred
) -
Remove
schedule
function frompromesa.core
(replaced bypromesa.exec/schedule
). -
Remove
extend-promise!
frompromesa.core
(still available inpromesa.impl
). -
Remove
set-default-promise!
helper (the user can do the same without the helper). -
Remove
attempt
function (not useful). -
Remove
branch
function (not useful).
New features and not breaking changes and fixes:
- Add
create
promise constructor, a facility for create a promise using a factory function (before this is done passing a function topromise
). - Add
deferred
promise constructor. The main purpose of this constructor is creating an empty promise ready to be resolved or rejected externally (usingresolve!
andreject!
). - Add
handle
chain function: is some kind of combination ofthen'
andcatch
. It chains a function to be executed when the promise is either normally or rejected (with first argument with resolved value (or nil) and second argument with the exception (or nil) if promise is rejected). Returns the promise resolved with the return value of the chained function. Does not flatten the result. - Add
then'
chain function. Is a variant ofthen
function that does not flatten the result (a more performant variant). - Add
chain'
chain function helper. Is achain
variant that does not flatten the result (a more performant variant). - Rename
alet
tolet
(alet
is stil awailable as alias for backward compatibility). - Add
plet
as syntactic abstraction/sugar forall
composition operator. - Add
race
composition operator. - Add
run!
function (a promise awarerun!
variant). - Add
promesa.exec
namespace with Executors & Schedulers abstractions. - Add
future
macro (analogous toclojure.core/future
that returns promise instance instead of Future, also works in cljs) that usespromesa.exec
behind the schenes. - Improve
let
macro making it safe to synchronos exception that can be raised from the first evaluated expression. Now all exception raised insidelet
returs properly rejected promise. - Add
loop/recur
syntax abstraction.
Date: 2019-08-21
This is a breaking change release; even though the majority of public (not experimental) api is not affected. Relevant changes are:
- Remove
promesa.async
andpromesa.async-cljs
namespaces. They was experimental and finally they don't demonstrate to be useful in comparison to the complexity that they introduce.
Other changes:
- Allow use promise on GraalVM native compilation.
- Make promesa compatible with thenable objects (see issue #66).
- Simplified
alet
macro implementation; it's no longer needsawait
for wait promise binding resolution.
Date: 2019-03-30
Yo now can create an empty promise (without a factory function) and
resolve or reject it using the new functions: resolve!
reject!
.
Example:
(require '[promesa.core :as p])
(let [pr (p/promise)]
;; do something
(p/resolve! pr 2))
Date: 2019-02-19
This is a breaking change release. Finally bluebird is gone in favour of using the ES6 builtin Promise object. This removes the overhead (in size) of the additional external library.
The reason of using bluebird initially was because native promises performed badly, but in new versions javascript engines the performance and memory usage is improved significantly. In any case you can still use the bluebird if you want, thanks to the new functions:
set-default-promise!
: enables the user setting up a custom promise constructor as default one for promesa library.extend-promise!
: enables the user to use a custom promise implementation with promesa library abstractions.
Other (also probably breaking) changes:
timeout
is now implemented in terms of internal scheduler facilities (bluebird impl was used previously) and it is now available for clojure (jvm).any
is reimplemented in clj/cljs and now accepts an additional argument for setting the default return value if promise is resolved. If default value is not provided, an ExceptionInfo will be throwed.
Date: 2018-08-03
- Update bluebird bundle to 3.5.0
- Update dependencies.
- Fix some issues on async macro (jvm only).
- Fix issue with interop on alet macros.
Date: 2017-04-20
- Remove
_
character from internal assets directory. That fixes incompatibilities with cordova/android build tools.
Date: 2017-02-21
- Update bluebird to 3.4.7
- Fix wrong impl of sync introspection (on cljs).
- Fix wrong impl of delay function (on cljs).
- Fix behavior difference of
then
function on clj in respect to cljs. - Avoid compiler warnings caused by .finally/.catch
- Add safer await detection on
async
macro (on cljs).
Date: 2016-12-18
- Fix clojure
finally
implementation. - Minor internal refactor. Public api should be fully backward compatible.
Date: 2016-11-02
- Add
async
macro that usescore.async
machinary in order to buildgo
like macro and allow to have fully async/await syntax. - Update bluebird to 3.4.6 (cljs underlying promise impl library).
- Add support experimental support for native promises and other thenables.
- Remove usage of
clj->js
andjs->clj
functions.
Date: 2016-08-18
- Make promise aware of clojure dynamic binding context (clj only).
Date: 2016-07-10
- Update bluebird to 3.4.1
- Add missing Promise alias on externs (that fixes unexpected exceptions on advanced compilation modes).
Date: 2016-06-08
- Remove reflection warnings.
Date: 2016-06-08
- Update bluebird to 3.4.0
- Improve internal impl (now splitted in few namespaces).
- Fix bug in
finally
combinator function. - Add
do*
promise constructor (analogous toPromise.attempt
). - Remove
promise.monad
namespace.
Date: 2016-05-20
- Add more bluebird externs.
- Docstrings improvements.
- Update bluebird to 3.3.5
Date: 2016-03-19
- Fix wrong call on IPrintWriter impl.
- Add noConflict to externs.
- Update cljs compiler to 1.8.34.
Date: 2016-03-18
- Add
err
anderror
alias ascatch
analougous function that has the parameters inverted in the same way asmap
andmapcat
.
Date: 2016-03-17
- Add scheduler abstraction.
- Add
map
function. - Add
mapcat
function. - Update bluebird to 3.3.4.
- Remove wrapping logic from -bind impl.
Date: 2016-02-13
- Remove cats imports from core ns that causes import exception.
Date: 2016-02-13
- BREAKING CHANGE: Cats is no longer requred dependency.
If you want use it you need import the
promesa.monad
ns. - Update bluebird to 3.3.0 (cljs).
- Add bultin support for
async/await
like syntax.
Date: 2016-01-08
- Update bluebird to 3.1.1 (cljs).
- Add better externs (with type annotations) (cljs).
- Update cats dependency to 1.2.1.
Date: 2015-12-03
Important changes:
- Add clojure support (only with JDK8). Tha implies major code refactor. The public api should be mostly backwad compatible but it is possible regressions.
Other changes:
- Update the cljs compiler version to 1.7.189
- Update cats library to 1.2.0
Date: 2015-09-27
- Add 'branch' combinator
Date: 2015-09-18
- Update cats to 1.0.0
- Adapt code to cats 1.0.0 breaking changes.
- Add more tests.
- Remove spread operator beacuse it is no longer needed (you can use clojure
destructuring with
then
combinator. - Start using the
-name
protocol naming convention. - Update bluebird to 2.10.0
Date: 2015-08-18
- Update cats dependency to 0.6.1
Date: 2015-08-02
- Update bluebird version to 2.9.34
- Update cljs compiler version to 1.7.28
- Start using cljs compiler own compilation facilities instead of lein-cljsbuld.
- Now requires the clojurescript >= 1.7.28
Date: 2015-07-18
- Remove all method related to cancellable promises.
- Implement everything in terms of protocols.
- Update bluebird version to 2.9.33
Date: 2015-06-13
- Go back to use leiningen.
- Update bluebird version to 2.9.27
Date: 2015-05-16
- Update bluebird version to 2.9.25
- Start using boot instead of leiningen
Date: 2015-04-16
- Update bluebird version to 2.9.23
Date: 2015-03-28
- First relase.