Commit Graph

4 Commits

Author SHA1 Message Date
Simon Brunel
1f30224578 Add support for creating promises from Qt signals (#25)
Introduce a new `QtPromise::connect()` helper that allows to create a promise resolved from a single signal and optionally, rejected by another one (from a different object or not). The promise type is determined by the type of the first signal argument (other arguments are currently ignored). A `QPromise<void>` is returned if the resolve signal doesn't provide any argument.

If the rejection is emitted before the promise is resolved, the promise will be rejected with the value of the first argument (other arguments being ignored). If the rejection signal doesn't provide any argument, the promise will be rejected with `QPromiseUndefinedException` if the signal is emitted. Additionally, the promise will be automatically rejected with `QPromiseContextException` if the source object is destroyed before the promise is resolved.
2019-03-04 14:02:32 +01:00
Simon Brunel
a6d883acbd Update LICENSE year and cleanup a few comments 2019-02-18 20:30:41 +01:00
Simon Brunel
5e754d1b08 Minor code style cleanup 2017-06-10 10:06:25 +02:00
Simon Brunel
596855f579 Move helpers in separate file and add unit tests
Gather helpers in `promisehelpers.h` and add a global include file to make easier integration with the lib (`#include <QtPromise>`).
2017-05-25 09:19:36 +02:00