-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (33 loc) · 684 Bytes
/
index.js
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
import { reactive } from "vue";
class Wait {
constructor() {
this.list = reactive({});
}
is(name) {
return !!this.list[name];
}
start(name) {
return !this.list[name] && (this.list[name] = Date.now());
}
end(name) {
const start = this.list[name];
delete this.list[name];
return Date.now() - start;
}
any() {
return Object.keys(this.list).length;
}
clear() {
let clearList = {};
Object.keys(this.list).forEach((item) => {
clearList[item] = this.end(item);
});
return clearList;
}
}
export const $wait = new Wait();
export default {
install: (app) => {
app.config.globalProperties.$wait = $wait;
},
};