Simon Brunel eebcb4f364 Migrate documentation to VuePress
GitBook development seems a bit stuck right now so let's switch to VuePress which, IMO, is more user friendly. Update the documentation to include the version number in which features were added and use custom container to display notes and warnings.
2018-09-09 10:55:07 +02:00

1.1 KiB

title
::all [static]

QPromise::all [static]

Since: 0.1.0

[static] QPromise<T>::all(Sequence<QPromise<T>> promises) -> QPromise<QVector<T>>

Returns a QPromise<QVector<T>> 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.

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.

Sequence is any STL compatible container (eg. QVector, QList, std::vector, etc.)

QVector<QPromise<QByteArray> > promises{
    download(QUrl("http://a...")),
    download(QUrl("http://b...")),
    download(QUrl("http://c..."))
};

auto output = QPromise<QByteArray>::all(promises);

// output type: QPromise<QVector<QByteArray>>
output.then([](const QVector<QByteArray>& res) {
    // {...}
});

See also: qPromiseAll