Skip to content

Commit

Permalink
Change the written strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jprodrigues70 committed Jan 13, 2021
1 parent 7b00cfa commit 75a323e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import { reactive } from "vue";

class Wait {
list = reactive({});
is = (name) => !!this.list[name];
start = (name) => !this.list[name] && (this.list[name] = Date.now());
end = (name) => {
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 = () => Object.keys(this.list).length;
clear = () => {
}
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();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meforma/vue-wait-for",
"version": "0.0.1",
"version": "0.0.2",
"description": "A loader manager for vuejs 3 with reactive method",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 75a323e

Please sign in to comment.