Skip to content

Commit 1331856

Browse files
authored
doc: add HandleScope example (#1210)
1 parent d5fc875 commit 1331856

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/handle_scope.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,17 @@ Napi::Env Napi::HandleScope::Env() const;
6161
```
6262

6363
Returns the `Napi::Env` associated with the `Napi::HandleScope`.
64+
65+
## Example
66+
67+
```cpp
68+
for (int i = 0; i < LOOP_MAX; i++) {
69+
Napi::HandleScope scope(info.Env());
70+
std::string name = std::string("inner-scope") + std::to_string(i);
71+
Napi::Value newValue = Napi::String::New(info.Env(), name.c_str());
72+
// do something with newValue
73+
};
74+
```
75+
76+
For more details refer to the section titled [Object lifetime
77+
management](object_lifetime_management.md).

0 commit comments

Comments
 (0)