-
Notifications
You must be signed in to change notification settings - Fork 0
/
IdleDeadline.cljs
51 lines (38 loc) · 1.77 KB
/
IdleDeadline.cljs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(ns web.other.IdleDeadline
"See our complete example in the article Cooperative Scheduling
Background Tasks API."
(:refer-clojure :exclude []))
(defn time-remaining
"Method.
The timeRemaining() method on the `web.other.IdleDeadline` interface
the estimated number of milliseconds remaining in the current
period. The callback can call this method at any time to determine
much time it can continue to work before it must return. For
if the callback finishes a task and has another one to begin,
can call timeRemaining() to see if there's enough time to complete
next task. If there isn't, the callback can just return immediately,
look for other work to do with the remaining time.
`timeRemaining = IdleDeadline.timeRemaining();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/IdleDeadline/timeRemaining`"
[this ]
(-> this (.timeRemaining)))
(defn did-timeout
"Property.
The read-only didTimeout property on the `web.other.IdleDeadline`
is a Boolean value which indicates whether or not the idle callback
being invoked because the timeout interval specified when `Window.requestIdleCallback()`
called has expired.
`var timedOut = IdleDeadline.didTimeout;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/IdleDeadline/didTimeout`"
[this]
(-> this (.-didTimeout)))
(defn set-did-timeout!
"Property.
The read-only didTimeout property on the `web.other.IdleDeadline`
is a Boolean value which indicates whether or not the idle callback
being invoked because the timeout interval specified when `Window.requestIdleCallback()`
called has expired.
`var timedOut = IdleDeadline.didTimeout;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/IdleDeadline/didTimeout`"
[this val]
(aset this "didTimeout" val))