[node] change request semantics

Passes a second, callback argument to the request implementation instead
of needing to call req.respond.
This commit is contained in:
Mike Morris
2015-09-10 15:54:06 -04:00
parent 532bbd5484
commit 1296f91c82
7 changed files with 27 additions and 24 deletions

View File

@@ -19,8 +19,6 @@ NAN_MODULE_INIT(NodeRequest::Init) {
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->SetClassName(Nan::New("Request").ToLocalChecked());
Nan::SetPrototypeMethod(tpl, "respond", Respond);
constructor.Reset(tpl->GetFunction());
Nan::Set(target, Nan::New("Request").ToLocalChecked(), tpl->GetFunction());
}
@@ -55,7 +53,7 @@ v8::Handle<v8::Object> NodeRequest::Create(NodeFileSource* source, const mbgl::R
}
NAN_METHOD(NodeRequest::Respond) {
auto nodeRequest = Nan::ObjectWrap::Unwrap<NodeRequest>(info.Holder());
auto nodeRequest = Nan::ObjectWrap::Unwrap<NodeRequest>(info.Data().As<v8::Object>());
// Request has already been responded to, or was canceled, fail silently.
if (!nodeRequest->resource) {