Date: 2022-02-24
with-redefs
macro to clj-kondo config (thanks to @eccentric-j)Date: 2022-02-23
promise?
to check for IPromise protocol instead of concrete types. Now it should
more easy extend promise to other promise like types.promise.core/do!
macro to promise.core/do
(backward compatible, previous
macro still in the codebase)with-redefs
macro (thanks to @eccentric-j)Date: 2022-02-22
promise?
to check for IPromise protocol instead of concrete
types. Because the impl was wrong.Date: 2022-02-22
promise?
to check for IPromise protocol instead of concrete
types.promesa.exec/with-dispatch
macro.Date: 2022-02-21
bind
function behave as it should behave (like bind and
not being then
alias). This is technically a breaking change,
the bind
function should have been implemented in terms of bind
operation and not be an alias for then
.Date: 2022-02-16
Date: 2022-02-12
as->
threading macro (thanks to @wilkerlucio)Date: 2022-02-03
->
and ->>
threading macros (thanks to @wilkerlucio)Date: 2021-06-01
timeout
internal timeout handling.Date: 2021-05-13
scheduled-pool
function.Date: 2020-10-01
Relevant changes:
Add missing -then
impl for default
object (fixes issues of
promesa.core/then
chain function with promises that does not
inherito from js/Promise
).
Remove already deprecated for a while the alet
alias to let
macro (the migration should be a simple find-and-replace).
Add forkjoin-pool and factory helpers to promesa.exec
ns.
Date: 2020-02-05
Relevant changes:
loop/recur
(make its scheduling extensible and by
default it uses the common thread pool for scheduling body execution
for prevet stack overflow).promesa.core/*loop-run-fn*
dynamic var for cases when you need
customize where the loop/recur body exection is scheduled.Date: 2020-01-10
Relevant changes:
catch
and handle
(enabling the same
semantic than then
function).catch'
variant for cases when you sure that funcion always
return a plain value (and not promise).promesa.core/plet
.promesa.core/let
with promesa.core/do!
macro.promesa.core/plet
with promesa.core/do!
macro.Date: 2019-10-03
Date: 2019-10-03
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 the
create
function, see below).
Remove the old do*
macro.
Add do!
macro (that should have been the do*
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
and mapcat
for provide a custom executor service if you
need it.
The promise
and deferred
(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 to deferred
)
Remove schedule
function from promesa.core
(replaced by promesa.exec/schedule
).
Remove extend-promise!
from promesa.core
(still available in promesa.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:
create
promise constructor, a facility for create a promise
using a factory function (before this is done passing a function to
promise
).deferred
promise constructor. The main purpose of this
constructor is creating an empty promise ready to be resolved or
rejected externally (using resolve!
and reject!
).handle
chain function: is some kind of combination of then'
and catch
. 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.then'
chain function. Is a variant of then
function that
does not flatten the result (a more performant variant).chain'
chain function helper. Is a chain
variant that does
not flatten the result (a more performant variant).alet
to let
(alet
is stil awailable as alias for
backward compatibility).plet
as syntactic abstraction/sugar for all
composition
operator.race
composition operator.run!
function (a promise aware run!
variant).promesa.exec
namespace with Executors & Schedulers abstractions.future
macro (analogous to clojure.core/future
that returns
promise instance instead of Future, also works in cljs) that uses
promesa.exec
behind the schenes.let
macro making it safe to synchronos exception that can
be raised from the first evaluated expression. Now all exception
raised inside let
returs properly rejected promise.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:
promesa.async
and promesa.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:
alet
macro implementation; it's no longer needs await
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
Date: 2017-04-20
_
character from internal assets directory. That fixes incompatibilities
with cordova/android build tools.Date: 2017-02-21
then
function on clj in respect to cljs.async
macro (on cljs).Date: 2016-12-18
finally
implementation.Date: 2016-11-02
async
macro that uses core.async
machinary in order to build go
like macro and allow to have fully async/await syntax.clj->js
and js->clj
functions.Date: 2016-08-18
Date: 2016-07-10
Date: 2016-06-08
Date: 2016-06-08
finally
combinator function.do*
promise constructor (analogous to Promise.attempt
).promise.monad
namespace.Date: 2016-05-20
Date: 2016-03-19
Date: 2016-03-18
err
and error
alias as catch
analougous function
that has the parameters inverted in the same way as map
and mapcat
.Date: 2016-03-17
map
function.mapcat
function.Date: 2016-02-13
Date: 2016-02-13
promesa.monad
ns.async/await
like syntax.Date: 2016-01-08
Date: 2015-12-03
Important changes:
Other changes:
Date: 2015-09-27
Date: 2015-09-18
then
combinator.-name
protocol naming convention.Date: 2015-08-18
Date: 2015-08-02
Date: 2015-07-18
Date: 2015-06-13
Date: 2015-05-16
Date: 2015-04-16
Date: 2015-03-28
Can you improve this documentation? These fine people already did:
Andrey Antukh & Alejandro GómezEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close