-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhello_async.hpp
More file actions
37 lines (30 loc) · 916 Bytes
/
hello_async.hpp
File metadata and controls
37 lines (30 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <nan.h>
namespace object_async {
/**
* HelloObject class
* This is in a header file so we can access it across other .cpp files if
* necessary
* Also, this class adheres to the rule of Zero because we define no custom
* destructor or copy constructor
*/
class HelloObjectAsync : public Nan::ObjectWrap
{
public:
// initializer
static void Init(v8::Local<v8::Object> target);
// methods required for the V8 constructor
static NAN_METHOD(New);
static Nan::Persistent<v8::Function>& create_once();
// helloAsync, custom async method tied to Init of this class
// method's logic lives in ./hello.cpp
static NAN_METHOD(helloAsync);
// C++ Constructor
// Passing the arg by rvalue reference (&&)
HelloObjectAsync(std::string&& name);
private:
// member variable
// specific to each instance of the class
std::string name_;
};
}