程序代写代做代考 ## Nan::Callback

## Nan::Callback

`Nan::Callback` makes it easier to use `v8::Function` handles as callbacks. A class that wraps a `v8::Function` handle, protecting it from garbage collection and making it particularly useful for storage and use across asynchronous execution.

Nan::Callback


### Nan::Callback

“`c++
class Callback {
public:
Callback();

explicit Callback(const v8::Local &fn);

~Callback();

bool operator==(const Callback &other) const;

bool operator!=(const Callback &other) const;

v8::Local operator*() const;

v8::Local operator()(v8::Local target,
int argc = 0,
v8::Local argv[] = 0) const;

v8::Local operator()(int argc = 0,
v8::Local argv[] = 0) const;

void SetFunction(const v8::Local &fn);

v8::Local GetFunction() const;

bool IsEmpty() const;

void Reset(const v8::Local &fn);

void Reset();

v8::Local Call(v8::Local target,
int argc,
v8::Local argv[]) const;

v8::Local Call(int argc, v8::Local argv[]) const;
};
“`

Example usage:

“`c++
v8::Local function;
Nan::Callback callback(function);
callback.Call(0, 0);
“`