194 |
195 | Carregando...
196 |
197 |
198 |
199 |
200 |
201 |
202 |
49 |
--------------------------------------------------------------------------------
/example/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Vuex, { Store } from 'vuex';
3 | import App from './App.vue'
4 | import Loadable from '../src/vue-loadable'
5 |
6 | Vue.use(Vuex)
7 |
8 | Vue.use(Loadable)
9 |
10 | const store = new Store({
11 | actions: {
12 | async w () {
13 | await new Promise((resolve) => setTimeout(resolve, 3000))
14 | }
15 | }
16 | })
17 |
18 | new Vue({
19 | el: '#app',
20 | store,
21 | render: (λ) => λ(App)
22 | })
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-loadable",
3 | "version": "0.2.0",
4 | "description": "Improves your loading state flow by providing methods and helpers to manage it.",
5 | "cdn": "dist/vue-loadable.umd.js",
6 | "types": "types/vue-loadable.d.ts",
7 | "main": "dist/vue-loadable.js",
8 | "unpkg": "dist/vue-loadable.umd.js",
9 | "module": "dist/vue-loadable.esm.js",
10 | "jsdelivr": "dist/vue-loadable.umd.js",
11 | "umd:main": "dist/vue-loadable.umd.js",
12 | "files": [
13 | "dist/",
14 | "types/"
15 | ],
16 | "scripts": {
17 | "build": "bili",
18 | "test": "ava",
19 | "serve": "poi --serve example/main.js",
20 | "prepare": "yarn test && yarn build"
21 | },
22 | "repository": {
23 | "type": "git",
24 | "url": "git+https://github.com/VitorLuizC/vue-loadable.git"
25 | },
26 | "keywords": [
27 | "vue",
28 | "vue-mixin",
29 | "loadable",
30 | "load",
31 | "vue-loadable"
32 | ],
33 | "author": {
34 | "url": "https://vitorluizc.github.io/",
35 | "name": "Vitor Cavalcanti",
36 | "email": "vitorluizc@outlook.com"
37 | },
38 | "license": "MIT",
39 | "bugs": {
40 | "url": "https://github.com/VitorLuizC/vue-loadable/issues"
41 | },
42 | "homepage": "https://github.com/VitorLuizC/vue-loadable#readme",
43 | "devDependencies": {
44 | "ava": "^2.4.0",
45 | "bili": "^4.8.1",
46 | "poi": "^12.7.3",
47 | "rollup-plugin-typescript2": "^0.24.3",
48 | "ts-node": "^8.4.1",
49 | "typescript": "^3.6.4",
50 | "vue": "^2.6.10",
51 | "vue-template-compiler": "^2.6.10",
52 | "vuex": "^3.1.1"
53 | },
54 | "ava": {
55 | "require": [
56 | "ts-node/register"
57 | ],
58 | "extensions": [
59 | "ts"
60 | ],
61 | "compileEnhancements": false
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/LoadableMixin.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 |
3 | /**
4 | * A mixin which adds loading states and helpers to Vue components.
5 | * @example ```js
6 | * Vue.component('SignUpForm', {
7 | * mixins: [ LoadableMixin ],
8 | * ...,
9 | * mounted () {
10 | * if (this.$isLoadingAny())
11 | * console.log('Loading...');
12 | * }
13 | * })```
14 | */
15 | const LoadableMixin = Vue.extend({
16 | data() {
17 | return {
18 | LOADING_STATES: Object.create(null) as Record