This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/doric/engine/DoricPromise.h

37 lines
992 B
C
Raw Normal View History

2021-04-22 11:43:48 +08:00
#ifndef DORICPROMISE_H
#define DORICPROMISE_H
#include <QDebug>
#include "DoricContext.h"
#include "utils/DoricConstant.h"
class DoricPromise {
public:
2021-04-22 14:48:16 +08:00
static void resolve(DoricContext *context, QString callbackId,
QVariantList args) {
2021-04-22 11:43:48 +08:00
QVariantList params;
params.append(context->getContextId());
params.append(callbackId);
2021-04-22 14:48:16 +08:00
foreach (QVariant arg, args) { params.append(arg); }
2021-04-22 11:43:48 +08:00
context->getDriver()->invokeDoricMethod(DoricConstant::DORIC_BRIDGE_RESOLVE,
params);
}
2021-04-22 13:42:38 +08:00
2021-04-22 14:48:16 +08:00
static void reject(DoricContext *context, QString callbackId,
QVariantList args) {
2021-04-22 13:42:38 +08:00
QVariantList params;
params.append(context->getContextId());
params.append(callbackId);
2021-04-22 14:48:16 +08:00
foreach (QVariant arg, args) { params.append(arg); }
2021-04-22 13:42:38 +08:00
context->getDriver()->invokeDoricMethod(DoricConstant::DORIC_BRIDGE_REJECT,
params);
}
2021-04-22 11:43:48 +08:00
};
#endif // DORICPROMISE_H