Improve chaining of notify actions
Currently, there are only two options when chaining notify actions: prevent that the returned promise is notified at all (callback returns void
) and notify the returned promise whenever the original promise is notified, possibly with a different value.
Instead, the chaining of notify actions should be more in line with resolve and reject actions which also makes it more flexible:
- when the callback returns
void
, the returned promise is notified with the same value as the original promise - when the callback returns
QVariant
, the returned promise is notified with the returned value - when the callback returns
Promise::Ptr
, the returned promise is notified whenever the promise returned by the callback is notified, using the same value
Returning Promise::Ptr
then gives full control of notifying the promises further down the chain:
- prevent notifying by simply not notifying the returned promise
- change the frequency by notifying the returned promise less/more often
Additionally, if the resolvedCallback
or the rejectedCallback
return a Promise::Ptr
the returned promise must be notified when then promise returned by the callback is notified, using the same value.
This effectively means that the returned promise is first notified by the notifiedCallback
and as soon as the original promise is resolved or rejected, it is notified by the promise returned by the callback.