Skip to content

Commit 9ef15ef

Browse files
yoyoysf
authored andcommitted
add typing (#62)
1 parent 35e1e4a commit 9ef15ef

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"url": "https://github.com/f/vue-wait/issues"
2222
},
2323
"main": "dist/vue-wait.js",
24+
"types": "src/types/index.d.ts",
2425
"files": [
2526
"dist",
2627
"src",

src/types/index.d.ts

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import Vue, { PluginFunction } from 'vue';
2+
import { Store } from 'vuex';
3+
4+
type AsyncFunction = ((any) => Promise<any>) | Promise<any>;
5+
6+
export default class VueWait extends VueWaitInstance {
7+
constructor(options?: VueWaitOptions);
8+
9+
static install(): PluginFunction<any>;
10+
11+
static init(Vue: Vue, store: Store<any>);
12+
}
13+
14+
/**
15+
* The vue-wait Instance
16+
*/
17+
18+
export class VueWaitInstance {
19+
/**
20+
* Returns boolean value if any loader exists in page.
21+
*
22+
* @returns {boolean}
23+
* @memberof VueWaitInstance
24+
*/
25+
any(): boolean;
26+
27+
/**
28+
* Returns boolean value if some of given loaders exists in page.
29+
*
30+
* @param {(string|string[])} waiter
31+
* @returns {boolean}
32+
* @memberof VueWaitInstance
33+
*/
34+
is(waiter: string|string[]): boolean;
35+
36+
/**
37+
* Returns boolean value if some of given loaders exists in page.
38+
*
39+
* @param {(string|string[])} waiter
40+
* @returns {boolean}
41+
* @memberof VueWaitInstance
42+
*/
43+
waiting(waiter: string|string[]): boolean;
44+
45+
/**
46+
* Returns the percentage of the given loader.
47+
*
48+
* @param {string} waiter
49+
* @returns {number}
50+
* @memberof VueWaitInstance
51+
*/
52+
percent(waiter: string): number;
53+
54+
/**
55+
* Starts the given loader.
56+
*
57+
* @param {string} waiter
58+
* @returns {void}
59+
* @memberof VueWaitInstance
60+
*/
61+
start(waiter: string): void;
62+
63+
/**
64+
* Stops the given loader.
65+
*
66+
* @param {string} waiter
67+
* @returns {void}
68+
* @memberof VueWaitInstance
69+
*/
70+
end(waiter: string): void;
71+
72+
/**
73+
* Sets the progress of the given loader.
74+
*
75+
* @param {string} waiter
76+
* @param {number} current
77+
* @param {number} [total]
78+
* @memberof VueWaitInstance
79+
*/
80+
progress(waiter: string, current: number, total?: number);
81+
82+
waitFor(waiter, callback: AsyncFunction, forceSync?: false): Promise<any>;
83+
waitFor(waiter, callback: Function, forceSync: true): Promise<any>;
84+
}
85+
86+
export interface VueWaitOptions{
87+
/**
88+
* You can change this value to rename the accessor. E.g. if you rename this to $w, your VueWait methods will be accessible by $w.waits(..) etc.
89+
*/
90+
accessorName?: string,
91+
/**
92+
* Use this value for enabling integration with Vuex store. When this value is true VueWait will store data in Vuex store and all changes to this data will be made by dispatching actions to store
93+
*/
94+
useVuex?: boolean,
95+
/**
96+
* Name for Vuex store if useVuex set to true, otherwise not used.
97+
*/
98+
vuexModuleName?: string,
99+
/**
100+
* Registers v-wait component.
101+
*/
102+
registerComponent?: boolean,
103+
/**
104+
* Changes v-wait component name.
105+
*/
106+
componentName?: string;
107+
/**
108+
* Registers v-wait directive.
109+
*/
110+
registerDirective?: boolean;
111+
/**
112+
* Changes v-wait directive name.
113+
*/
114+
directiveName?: string;
115+
}

0 commit comments

Comments
 (0)