1 #ifndef VARIANTPROMISE_H
2 #define VARIANTPROMISE_H
6 class VariantPromise : public QObject {
10 explicit VariantPromise(QObject *parent = nullptr) : QObject(parent) {
11 connect(this, &VariantPromise::resolve, this, &QObject::deleteLater);
12 connect(this, &VariantPromise::reject, this, &QObject::deleteLater);
15 template <typename Function> VariantPromise &then(Function func) {
16 connect(this, &VariantPromise::resolve, this, func);
19 template <typename Function> VariantPromise &onFailed(Function func) {
20 connect(this, &VariantPromise::reject, this, func);
23 template <typename Function> VariantPromise &finally(Function func) {
24 connect(this, &VariantPromise::destroyed, this, func);
29 void resolve(QVariant result);
30 void reject(const QString &message);
33 #endif // VARIANTPROMISE_H