Skip to content

Commit

Permalink
doc: add HandleScope example (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEady authored Sep 23, 2022
1 parent d5fc875 commit 1331856
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/handle_scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,17 @@ Napi::Env Napi::HandleScope::Env() const;
```

Returns the `Napi::Env` associated with the `Napi::HandleScope`.

## Example

```cpp
for (int i = 0; i < LOOP_MAX; i++) {
Napi::HandleScope scope(info.Env());
std::string name = std::string("inner-scope") + std::to_string(i);
Napi::Value newValue = Napi::String::New(info.Env(), name.c_str());
// do something with newValue
};
```

For more details refer to the section titled [Object lifetime
management](object_lifetime_management.md).

0 comments on commit 1331856

Please sign in to comment.