• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# LoopObserver
2
3The **LoopObserver** module defines an observer to listen for event processing timeout. It can be used as an input parameter in [ErrorManager.on](./js-apis-app-ability-errorManager.md#errormanageron) to listen for the event processing time of the current application's main thread.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import errorManager from '@ohos.app.ability.errorManager';
13```
14
15## LoopObserver.onLoopTimeOut
16
17onLoopTimeOut?(timeout: number): void
18
19Called when a timeout occurs for the main thread to process an event in the JS runtime.
20
21**System capability**: SystemCapability.Ability.AbilityRuntime.Core
22
23**Parameters**
24
25| Name| Type| Mandatory| Description|
26| -------- | -------- | -------- | -------- |
27| timeout | number | Yes| Actual execution time of the main thread.|
28
29**Example**
30
31```ts
32import errorManager from '@ohos.app.ability.errorManager';
33
34let observer: errorManager.LoopObserver = {
35    onLoopTimeOut(timeout: number) {
36        console.log('Duration timeout: ' + timeout);
37    }
38};
39errorManager.on("loopObserver", 1, observer);
40```
41