Skip to content

Commit

Permalink
doc: update examples for context sensitivity
Browse files Browse the repository at this point in the history
Fixes: #1011

PR-URL: #1013
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
  • Loading branch information
KevinEady authored and mhdawson committed Jul 9, 2021
1 parent 37a9b8e commit 627dbf3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions doc/class_property_descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class Example : public Napi::ObjectWrap<Example> {
Example(const Napi::CallbackInfo &info);

private:
static Napi::FunctionReference constructor;
double _value;
Napi::Value GetValue(const Napi::CallbackInfo &info);
void SetValue(const Napi::CallbackInfo &info, const Napi::Value &value);
Expand All @@ -31,8 +30,9 @@ Napi::Object Example::Init(Napi::Env env, Napi::Object exports) {
InstanceAccessor<&Example::GetValue>("readOnlyProp")
});

constructor = Napi::Persistent(func);
constructor.SuppressDestruct();
Napi::FunctionReference *constructor = new Napi::FunctionReference();
*constructor = Napi::Persistent(func);
env.SetInstanceData(constructor);
exports.Set("Example", func);

return exports;
Expand All @@ -45,8 +45,6 @@ Example::Example(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Example>(inf
this->_value = value.DoubleValue();
}

Napi::FunctionReference Example::constructor;

Napi::Value Example::GetValue(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();
return Napi::Number::New(env, this->_value);
Expand Down

0 comments on commit 627dbf3

Please sign in to comment.