idle-observer
Reactive icon

Idle Observer

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 20 October 2024
 by 
0.0
 (0 ratings)
idle-observer

Idle Observer

Documentation
1.0.0

Client Actions (Global Instance):

- Global_IdleObserver_IsInitialized: It checks if the instance has been created..

- Global_IdleObserver_Start: It create a global instance.

- Global_GetState: Returns the current state (acive, idle, locked, unlocked).

- Global_IdleObserver_Destroy: It destroys the global instance


Client Actions (Local Instance):

- Local_IdleObserver_Destroy: It destroys the local instance

- Local_IdleObserver_Start: Creates a instance and returns an object.


Other Client Actions:

- ConvertStateResponse: Convert JSON into a sctructure

- IdleObserver_CheckBrowserCompability: It checks if the Idle Detector API is compatible according to the current browser.

- IdleObserver_IsLoaded: It checks if the script has been loaded.


Static Entities:

- ScreenState: Holds possibilities related to the screen state.

- USerState: Holds possibilities related to the user state.


You can also call methods and properties through the object instance:

Constructor: IdleObserver

Example:

options = {};

options.timeout= 60000;

options.eventHandler = $actions.Trigger_IdleActionHandler.

options.log = true;

window.idleObserver = new IdleObserver(options);

window.idleObserver.requestPermission.then((result) => {

  if (result.success)

      window.idleObserver.init();

})


Options:

timeout: integer (min 60 for client action and 60000 for object instance).

eventHandler: callback object.

log: Boolean. (Allows to log on console).


Properties:

#_permissionGranted: Boolean.

#_controller = AbortController.

#_response = null, "granted" or "denied".


Methods:

#_log: Logs on console. 

triggerEventHandler: Triggers the callback.

getState: Return the current user/screen state.

requestPermission: Promise. Requests permission for monitoring the user's activity (it requires an use gesture).

init: Initializes the instance.

destroy: Destroys the instance.