aboutsummaryrefslogtreecommitdiff
path: root/docs/02.API-REFERENCE.md
diff options
context:
space:
mode:
authorZoltan Herczeg <zherczeg.u-szeged@partner.samsung.com>2021-02-24 10:31:08 +0100
committerGitHub <noreply@github.com>2021-02-24 10:31:08 +0100
commitc27047da03a76b1467efb345444c3f8f315d3feb (patch)
tree52f5281e49b3f05bb0bfb24666fa8eacea39e242 /docs/02.API-REFERENCE.md
parentf0f2a28109a18b6b624a723f8f57a55cdbc35e0a (diff)
Add filters and more events to Promise callback. (#4605)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
Diffstat (limited to 'docs/02.API-REFERENCE.md')
-rw-r--r--docs/02.API-REFERENCE.md56
1 files changed, 54 insertions, 2 deletions
diff --git a/docs/02.API-REFERENCE.md b/docs/02.API-REFERENCE.md
index a6691546..26f02541 100644
--- a/docs/02.API-REFERENCE.md
+++ b/docs/02.API-REFERENCE.md
@@ -908,6 +908,19 @@ Possible values:
- JERRY_PROMISE_EVENT_REJECT - Called when a Promise is about to be rejected.
- object - the Promise object
- value - value for rejecting.
+- JERRY_PROMISE_EVENT_RESOLVE_FULFILLED - Called when a resolve is called on a fulfilled Promise.
+ - object - the Promise object
+ - value - value for resolving
+- JERRY_PROMISE_EVENT_REJECT_FULFILLED - Called when a reject is called on a fulfilled Promise.
+ - object - the Promise object
+ - value - value for rejecting
+- JERRY_PROMISE_EVENT_REJECT_WITHOUT_HANDLER - Called when a Promise is rejected without a handler.
+ - object - the Promise object
+ - value - value for rejecting
+- JERRY_PROMISE_EVENT_CATCH_HANDLER_ADDED - Called when a catch handler is added to a rejected
+ Promise which did not have a catch handler before.
+ - object - the Promise object
+ - value - undefined
- JERRY_PROMISE_EVENT_BEFORE_REACTION_JOB - Called before executing a Promise reaction job.
- object - the Promise object
- value - undefined
@@ -938,6 +951,43 @@ Possible values:
- [jerry_promise_set_callback](#jerry_promise_set_callback)
+## jerry_promise_event_filter_t
+
+Filter types for [jerry_promise_set_callback](#jerry_promise_set_callback) callback function.
+The callback is only called for those events which are enabled by the filters. The events are
+described in [jerry_promise_event_type_t](#jerry_promise_event_type_t).
+
+Possible values:
+
+- JERRY_PROMISE_EVENT_FILTER_DISABLE - Disable reporting of all events.
+- JERRY_PROMISE_EVENT_FILTER_MAIN - Enables the following events:
+ - JERRY_PROMISE_EVENT_CREATE
+ - JERRY_PROMISE_EVENT_RESOLVE
+ - JERRY_PROMISE_EVENT_REJECT
+- JERRY_PROMISE_EVENT_FILTER_ERROR - Enables the following events:
+ - JERRY_PROMISE_EVENT_RESOLVE_FULFILLED
+ - JERRY_PROMISE_EVENT_REJECT_FULFILLED
+ - JERRY_PROMISE_EVENT_REJECT_WITHOUT_HANDLER
+ - JERRY_PROMISE_EVENT_CATCH_HANDLER_ADDED
+- JERRY_PROMISE_EVENT_FILTER_REACTION_JOB - Enables the following events:
+ - JERRY_PROMISE_EVENT_BEFORE_REACTION_JOB
+ - JERRY_PROMISE_EVENT_AFTER_REACTION_JOB
+- JERRY_PROMISE_EVENT_FILTER_ASYNC_MAIN - Enables the following events:
+ - JERRY_PROMISE_EVENT_ASYNC_AWAIT
+- JERRY_PROMISE_EVENT_FILTER_ASYNC_REACTION_JOB - Enables the following events:
+ - JERRY_PROMISE_EVENT_ASYNC_BEFORE_RESOLVE
+ - JERRY_PROMISE_EVENT_ASYNC_BEFORE_REJECT
+ - JERRY_PROMISE_EVENT_ASYNC_AFTER_RESOLVE
+ - JERRY_PROMISE_EVENT_ASYNC_AFTER_REJECT
+
+*New in version [[NEXT_RELEASE]]*.
+
+**See also**
+
+- [jerry_promise_event_type_t](#jerry_promise_event_type_t)
+- [jerry_promise_set_callback](#jerry_promise_set_callback)
+
+
## jerry_promise_callback_t
**Summary**
@@ -4311,9 +4361,11 @@ Sets a callback for tracking Promise and async operations.
**Prototype**
```c
-void jerry_promise_set_callback (jerry_promise_callback_t callback, void *user_p);
+void jerry_promise_set_callback (jerry_promise_event_filter_t filters, jerry_promise_callback_t callback,
+ void *user_p);
```
+- `filters` - combination of [jerry_promise_event_filter_t](#jerry_promise_event_filter_t) options
- `callback` - callback function, the previously set value is overwritten,
and setting NULL disables the tracking
- `user_p` - pointer passed to the callback function, can be NULL
@@ -4351,7 +4403,7 @@ main (void)
{
jerry_init (JERRY_INIT_EMPTY);
- jerry_promise_set_callback (promise_callback, NULL);
+ jerry_promise_set_callback (JERRY_PROMISE_EVENT_FILTER_MAIN, promise_callback, NULL);
const char *source_p = "var p = Promise.resolve(0)\n"
"p.then(function (v) { return v; })";