diff --git a/README.md b/README.md index 886377d0d8d12ee566c64b93a46d7a81aeef0dfc..76484bc6f0484a8fd3dd7dd94e1d0d4fe6feab00 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ The following example describes how to use NAPI to develop a JS API for obtainin The prototype of the JS API is as follows: ``` -function getAppName(): string; +function getAppName(): Promise; ``` The implementation code of the JS API is as follows: diff --git a/README_zh.md b/README_zh.md index 719a1db8cc88133fcde0bd6290e50b9119ce5492..0dff0a93bcba224bd29772c06a3a1936c08f899d 100644 --- a/README_zh.md +++ b/README_zh.md @@ -147,7 +147,7 @@ NAPI适合封装IO、CPU密集型、OS底层等能力并对外暴露JS接口, 我们要实现的JS接口原型是: ``` -function getAppName(): string; +function getAppName(): Promise; ``` 以下是实现源码: @@ -180,7 +180,7 @@ napi_value JSGetAppName(napi_env env, napi_callback_info info) { napi_value resourceName; napi_create_string_latin1(env, "GetAppName", NAPI_AUTO_LENGTH, &resourceName); - // 创建异步任务队列 + // 创建异步任务并加入队列 napi_create_async_work( env, nullptr, resourceName, // 异步任务的回调