UNPKG

2.46 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Revue=e():t.Revue=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";function n(t,e){t.prototype.$subscribe=function(){for(var r=this,n=arguments.length,a=Array(n),u=0;n>u;u++)a[u]=arguments[u];if(this._calledOnce){if(s)throw new Error("[Revue] You can only subscribe once, pass multi args to subscribe more than one state.");return!1}this._calledOnce=!0;var c=function(){a.forEach(function(t){var n=t,s=t;if(i.test(t)){var a=t.match(i),u=o.slicedToArray(a,3);s=u[1],n=u[2]}if(n&&s){var c=e.getState()[s];r.$set(n,c)}})};this._unsubscribe=e.subscribe(c),t.mixin({beforeDestroy:function(){this._unsubscribe&&(this._calledOnce=!1,this.unsubscribe())}})}}var o={};o.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},o.createClass=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o.slicedToArray=function(){function t(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);n=!0);}catch(u){o=!0,i=u}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();var i=/^([a-zA-Z0-9_-]+)\s{1,2}as\s{1,2}([a-zA-Z0-9\._-]+)$/i,s=!1,a=function(){function t(e,r,i){o.classCallCheck(this,t),this.store=r,n(e,this.store),i&&(this.reduxActions=i)}return o.createClass(t,[{key:"dispatch",value:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.store.dispatch.apply(null,e),this}},{key:"state",get:function(){return this.store.getState()}},{key:"actions",get:function(){if(s&&!this.reduxActions)throw new Error("[Revue] Binding actions to Revue before calling them!");return this.reduxActions}}]),t}();t.exports=a}])});
\No newline at end of file