Differential D18758 Diff 58398 kdevplatform/3rdparty/qtpromise/qtpromise-0.5.0/docs/qtpromise/helpers/all.md
Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/3rdparty/qtpromise/qtpromise-0.5.0/docs/qtpromise/helpers/all.md
- This file was added.
1 | --- | ||||
---|---|---|---|---|---|
2 | title: all | ||||
3 | --- | ||||
4 | | ||||
5 | # QtPromise::all | ||||
6 | | ||||
7 | *Since: 0.5.0* | ||||
8 | | ||||
9 | ``` | ||||
10 | QtPromise::all(Sequence<QPromise<T>> promises) -> QPromise<QVector<T>> | ||||
11 | QtPromise::all(Sequence<QPromise<void>> promises) -> QPromise<void> | ||||
12 | ``` | ||||
13 | | ||||
14 | Returns a `QPromise<QVector<T>>` (or `QPromise<void>`) that fulfills when **all** `promises` of (the same) type `T` have been fulfilled. The `output` value is a vector containing all the values of `promises`, in the same order, i.e., at the respective positions to the original sequence, regardless of completion order. | ||||
15 | | ||||
16 | If any of the given `promises` fail, `output` immediately rejects with the error of the promise that rejected, whether or not the other promises are resolved. | ||||
17 | | ||||
18 | `Sequence` is any STL compatible container (eg. `QVector`, `QList`, `std::vector`, etc.) | ||||
19 | | ||||
20 | ```cpp | ||||
21 | QVector<QPromise<QByteArray> > promises{ | ||||
22 | download(QUrl("http://a...")), | ||||
23 | download(QUrl("http://b...")), | ||||
24 | download(QUrl("http://c...")) | ||||
25 | }; | ||||
26 | | ||||
27 | auto output = QtPromise::all(promises); | ||||
28 | | ||||
29 | // output type: QPromise<QVector<QByteArray>> | ||||
30 | output.then([](const QVector<QByteArray>& res) { | ||||
31 | // {...} | ||||
32 | }); | ||||
33 | ``` |