vue-loadable
Version:
Improves your loading state flow by providing methods and helpers to manage it.
8 lines (7 loc) • 1.84 kB
JavaScript
/*!
* vue-loadable v0.2.0
* (c) Vitor Cavalcanti <vitorluizc@outlook.com> (https://vitorluizc.github.io)
* Released under the MIT License.
*/
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],e):e((n=n||self).VueLoadable={},n.Vue)}(this,function(n,e){"use strict";var t=(e=e&&e.hasOwnProperty("default")?e.default:e).extend({data:function(){return{LOADING_STATES:Object.create(null)}},methods:{$isLoading:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"unknown",e=this.LOADING_STATES[n];return!!e&&e>0},$isLoadingAny:function(){return Object.keys(this.LOADING_STATES).some(this.$isLoading)},$setLoading:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"unknown",e=this.LOADING_STATES[n];this.$set(this.LOADING_STATES,n,e?e+1:1)},$unsetLoading:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"unknown",e=this.LOADING_STATES[n];this.$set(this.LOADING_STATES,n,e?e-1:0)}}}),i=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"unknown";return function(){var t=this,i=arguments;return this.$setLoading(e),function(n,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,i=function(n){return t(),Promise.reject(n)};try{return Promise.resolve(n()).then(function(n){return e(),Promise.resolve(n)}).catch(i)}catch(n){return i(n)}}(function(){return n.apply(t,i)},function(){return t.$unsetLoading(e)})}};function o(n){n.mixin(t)}var r={install:o};n.LoadableMixin=t,n.default=r,n.install=o,n.loadable=i,n.mapLoadableMethods=function(n){return Object.keys(n).reduce(function(e,t){return e[t]=i(n[t],t),e},Object.create(null))},Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=vue-loadable.umd.min.js.map