s-vuex-class
Version:
Binding helpers for Vuex and vue-class-component
10 lines • 1.52 kB
JavaScript
/*!
* ms-vuex-class v0.4.0
* https://github.com/MasterShu/vuex-class
*
* @license
* Copyright (c) 2017 Master Shu
* Released under the MIT license
* https://github.com/MasterShu/vuex-class/blob/master/LICENSE
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue-class-component"),require("vuex")):"function"==typeof define&&define.amd?define(["exports","vue-class-component","vuex"],t):t(e.VuexClass={},e.VueClassComponent,e.Vuex)}(this,function(e,t,n){"use strict";var o=i("computed",n.mapState),r=i("computed",n.mapGetters),a=i("methods",n.mapActions),u=i("methods",n.mapMutations);function i(u,i){function r(r,a){return t.createDecorator(function(e,t){e[u]||(e[u]={});var n,o=((n={})[t]=r,n);e[u][t]=void 0!==a?i(a,o)[t]:i(o)[t]})}return function(e,t){if("string"==typeof t){var n=t,o=e;return r(n,void 0)(o,n)}return r(e,function(e){var t=e&&e.namespace;if("string"==typeof t)return"/"!==t[t.length-1]?t+"/":t}(t))}}e.State=o,e.Getter=r,e.Action=a,e.Mutation=u,e.namespace=function(c,e){function t(i){return function(e,t){if("string"==typeof t){var n=t,o=e;return i(n,{namespace:c})(o,n)}var r,a=e,u=(r={},[t||{},{namespace:c}].forEach(function(t){Object.keys(t).forEach(function(e){r[e]=t[e]})}),r);return i(a,u)}}return e?(console.warn("[vuex-class] passing the 2nd argument to `namespace` function is deprecated. pass only namespace string instead."),t(e)):{State:t(o),Getter:t(r),Mutation:t(u),Action:t(a)}},Object.defineProperty(e,"__esModule",{value:!0})});