Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Env() to Promise::Deferred. #318

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/promises.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ Promise::Deferred(napi_env env);

* `[in] env`: The `napi_env` environment in which to construct the Deferred object.

### Env

```cpp
Napi::Env Env() const;
```

Returns the Env environment this Promise::Deferred object is associated with.

### Promise

```cpp
Expand Down
4 changes: 4 additions & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,10 @@ inline Promise Promise::Deferred::Promise() const {
return Napi::Promise(_env, _promise);
}

inline Napi::Env Promise::Deferred::Env() const {
return Napi::Env(_env);
}

inline void Promise::Deferred::Resolve(napi_value value) const {
napi_status status = napi_resolve_deferred(_env, _deferred, value);
NAPI_THROW_IF_FAILED(_env, status);
Expand Down
1 change: 1 addition & 0 deletions napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ namespace Napi {
Deferred(napi_env env);

Napi::Promise Promise() const;
Napi::Env Env() const;

void Resolve(napi_value value) const;
void Reject(napi_value value) const;
Expand Down