mirror of
https://github.com/zoriya/nitro.git
synced 2026-10-13 00:05:23 +00:00
34 lines
681 B
C++
34 lines
681 B
C++
#pragma once
|
|
|
|
#include <jsi/jsi.h>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace margelo {
|
|
|
|
using namespace facebook;
|
|
|
|
class Promise {
|
|
public:
|
|
Promise(jsi::Runtime& runtime, jsi::Function&& resolver, jsi::Function&& rejecter);
|
|
|
|
void resolve(jsi::Value&& result);
|
|
void reject(std::string error);
|
|
|
|
public:
|
|
jsi::Runtime& runtime;
|
|
|
|
private:
|
|
jsi::Function _resolver;
|
|
jsi::Function _rejecter;
|
|
|
|
public:
|
|
using RunPromise = std::function<void(jsi::Runtime& runtime, std::shared_ptr<Promise> promise)>;
|
|
/**
|
|
Create a new Promise and runs the given `run` function.
|
|
*/
|
|
static jsi::Value createPromise(jsi::Runtime& runtime, RunPromise run);
|
|
};
|
|
|
|
} // namespace margelo
|