Skip to content

Improve promise documentation #1666

@mhdawson

Description

@mhdawson

Based on team discussion in #1658, we agreed that we should improve the documentation to help people avoid what might be a easy mistake to make.

It was noted that

node-addon-api/napi.h

Lines 1556 to 1578 in ff6a672

class Promise : public Object {
public:
class Deferred {
public:
static Deferred New(napi_env env);
Deferred(napi_env env);
Napi::Promise Promise() const;
Napi::Env Env() const;
void Resolve(napi_value value) const;
void Reject(napi_value value) const;
private:
napi_env _env;
napi_deferred _deferred;
napi_value _promise;
};
static void CheckCast(napi_env env, napi_value value);
Promise(napi_env env, napi_value value);
};
in the C API does not have catch or then methonds, however, it should be possible to add them to the C++ API to help make it easier to use them properly.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions