-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (26 loc) · 788 Bytes
/
index.js
File metadata and controls
27 lines (26 loc) · 788 Bytes
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
export function subscribeTimeout(callback, timeout, thisArg, disposables) {
const cb = !thisArg ? callback : callback.bind(thisArg);
const id = setTimeout(cb, timeout);
const result = {
dispose() {
clearTimeout(id);
},
};
if (disposables && typeof disposables.push === 'function') {
disposables.push(result);
}
return result;
}
export function subscribeInterval(callback, timeout, thisArg, disposables) {
const cb = !thisArg ? callback : callback.bind(thisArg);
const id = setInterval(cb, timeout);
const result = {
dispose() {
clearInterval(id);
},
};
if (disposables && typeof disposables.push === 'function') {
disposables.push(result);
}
return result;
}