[node] NodeRequest inherits from Nan::AsyncWorker

drop NodeRequest::Create, move MakeCallback to NodeRequest::Execute

rework Respond -> HandleCallback

modern NAN style updates
This commit is contained in:
Mike Morris
2016-07-12 18:37:28 -04:00
parent 480be63396
commit 7df0e459b6
7 changed files with 153 additions and 156 deletions

View File

@@ -11,29 +11,31 @@
namespace node_mbgl {
class NodeFileSource;
class NodeRequest;
class NodeMap;
class NodeRequest : public Nan::ObjectWrap {
class NodeRequest : public Nan::ObjectWrap,
public Nan::AsyncWorker {
public:
static NAN_MODULE_INIT(Init);
static NAN_METHOD(New);
static NAN_METHOD(Respond);
static v8::Handle<v8::Object> Create(const mbgl::Resource&, mbgl::FileSource::Callback);
static Nan::Persistent<v8::Function> constructor;
NodeRequest(mbgl::FileSource::Callback);
~NodeRequest();
struct NodeAsyncRequest : public mbgl::AsyncRequest {
NodeAsyncRequest(NodeRequest*);
~NodeAsyncRequest() override;
NodeRequest* request;
};
NodeRequest(NodeMap*, mbgl::FileSource::Callback);
~NodeRequest();
static Nan::Persistent<v8::Function> constructor;
static NAN_MODULE_INIT(Init);
static void New(const Nan::FunctionCallbackInfo<v8::Value>&);
static void HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>&);
void Execute();
private:
NodeMap* target;
mbgl::FileSource::Callback callback;
NodeAsyncRequest* asyncRequest = nullptr;
};