-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
33 lines (32 loc) · 1.09 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* The store's internal state. Use this value
* to determine if the user has already taken
* any action and if the listener is granted.
*/
export type IdleDetectionSubscriptionState =
// No state changes yet.
| "init"
// Agent (aka browser) doesn't support the feature.
| "not-supported"
// User doesn't allow the API, no permission granted.
| "not-permitted"
// Supported + permission granted, but not yet listening.
| "ready"
// Listening to change events.
| "started"
// Detached listener, no changes will be registered.
| "stopped";
export type SubscribeToIdleDetectionParams = {
/**
* Seconds for timeout window between events.
* Please note that the browser might require a minimum of 60 sec,
* thus 1 minute as threshold to allow the API-call.
*/
threshold?: number;
/**
* Callback for state changes regarding the store-state.
*/
onStateChange: (next: IdleDetectionSubscriptionState) => void;
/** Callback for value changes, which are provided by the API. */
onEventChange: (parmas: Pick<IdleDetector, "userState" | "screenState">) => void;
};