Skip to content

Commit

Permalink
add typing (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyoys authored and f committed Nov 12, 2018
1 parent 35e1e4a commit 9ef15ef
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"url": "https://github.com/f/vue-wait/issues"
},
"main": "dist/vue-wait.js",
"types": "src/types/index.d.ts",
"files": [
"dist",
"src",
Expand Down
115 changes: 115 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import Vue, { PluginFunction } from 'vue';
import { Store } from 'vuex';

type AsyncFunction = ((any) => Promise<any>) | Promise<any>;

export default class VueWait extends VueWaitInstance {
constructor(options?: VueWaitOptions);

static install(): PluginFunction<any>;

static init(Vue: Vue, store: Store<any>);
}

/**
* The vue-wait Instance
*/

export class VueWaitInstance {
/**
* Returns boolean value if any loader exists in page.
*
* @returns {boolean}
* @memberof VueWaitInstance
*/
any(): boolean;

/**
* Returns boolean value if some of given loaders exists in page.
*
* @param {(string|string[])} waiter
* @returns {boolean}
* @memberof VueWaitInstance
*/
is(waiter: string|string[]): boolean;

/**
* Returns boolean value if some of given loaders exists in page.
*
* @param {(string|string[])} waiter
* @returns {boolean}
* @memberof VueWaitInstance
*/
waiting(waiter: string|string[]): boolean;

/**
* Returns the percentage of the given loader.
*
* @param {string} waiter
* @returns {number}
* @memberof VueWaitInstance
*/
percent(waiter: string): number;

/**
* Starts the given loader.
*
* @param {string} waiter
* @returns {void}
* @memberof VueWaitInstance
*/
start(waiter: string): void;

/**
* Stops the given loader.
*
* @param {string} waiter
* @returns {void}
* @memberof VueWaitInstance
*/
end(waiter: string): void;

/**
* Sets the progress of the given loader.
*
* @param {string} waiter
* @param {number} current
* @param {number} [total]
* @memberof VueWaitInstance
*/
progress(waiter: string, current: number, total?: number);

waitFor(waiter, callback: AsyncFunction, forceSync?: false): Promise<any>;
waitFor(waiter, callback: Function, forceSync: true): Promise<any>;
}

export interface VueWaitOptions{
/**
* 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.
*/
accessorName?: string,
/**
* 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
*/
useVuex?: boolean,
/**
* Name for Vuex store if useVuex set to true, otherwise not used.
*/
vuexModuleName?: string,
/**
* Registers v-wait component.
*/
registerComponent?: boolean,
/**
* Changes v-wait component name.
*/
componentName?: string;
/**
* Registers v-wait directive.
*/
registerDirective?: boolean;
/**
* Changes v-wait directive name.
*/
directiveName?: string;
}

0 comments on commit 9ef15ef

Please sign in to comment.