Skip to content

Commit 75a323e

Browse files
committed
Change the written strategy
1 parent 7b00cfa commit 75a323e

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

index.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
import { reactive } from "vue";
22

33
class Wait {
4-
list = reactive({});
5-
is = (name) => !!this.list[name];
6-
start = (name) => !this.list[name] && (this.list[name] = Date.now());
7-
end = (name) => {
4+
constructor() {
5+
this.list = reactive({});
6+
}
7+
is(name) {
8+
return !!this.list[name];
9+
}
10+
start(name) {
11+
return !this.list[name] && (this.list[name] = Date.now());
12+
}
13+
end(name) {
814
const start = this.list[name];
915
delete this.list[name];
1016
return Date.now() - start;
11-
};
12-
any = () => Object.keys(this.list).length;
13-
clear = () => {
17+
}
18+
any() {
19+
return Object.keys(this.list).length;
20+
}
21+
clear() {
1422
let clearList = {};
1523
Object.keys(this.list).forEach((item) => {
1624
clearList[item] = this.end(item);
1725
});
1826
return clearList;
19-
};
27+
}
2028
}
2129

2230
export const $wait = new Wait();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@meforma/vue-wait-for",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "A loader manager for vuejs 3 with reactive method",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)