Skip to content

Commit 627dbf3

Browse files
KevinEadymhdawson
authored andcommitted
doc: update examples for context sensitivity
Fixes: #1011 PR-URL: #1013 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 37a9b8e commit 627dbf3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

doc/class_property_descriptor.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class Example : public Napi::ObjectWrap<Example> {
1717
Example(const Napi::CallbackInfo &info);
1818

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

34-
constructor = Napi::Persistent(func);
35-
constructor.SuppressDestruct();
33+
Napi::FunctionReference *constructor = new Napi::FunctionReference();
34+
*constructor = Napi::Persistent(func);
35+
env.SetInstanceData(constructor);
3636
exports.Set("Example", func);
3737

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

48-
Napi::FunctionReference Example::constructor;
49-
5048
Napi::Value Example::GetValue(const Napi::CallbackInfo &info) {
5149
Napi::Env env = info.Env();
5250
return Napi::Number::New(env, this->_value);

0 commit comments

Comments
 (0)