├── LICENSE ├── README.md ├── img └── logo.png ├── vue-simple-store.js └── vue-simple-store.min.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Naufal Rabbani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | # Vue Simple Store 4 | Vue Simple Store is a vue plugin which will simplify your App Store. It will combine your separated stores into one global store. let's take a peek! 5 | 6 | ## [HOME PAGE](https://bosnaufal.github.io/vue-simple-store) 7 | 8 | ## Examples 9 | - [Vue Mini Shop](https://github.com/BosNaufal/vue-mini-shop) 10 | 11 | ## Thank You for Making this become useful~ 12 | Hopefully it can be useful for your next projects. 13 | 14 | ## Let's talk about some projects 15 | Just Contact Me At: 16 | - Email: [bosnaufalemail@gmail.com](mailto:bosnaufalemail@gmail.com) 17 | - Skype Id: bosnaufal254 18 | - twitter: [@BosNaufal](https://twitter.com/BosNaufal) 19 | 20 | ## License 21 | [MIT](http://opensource.org/licenses/MIT) 22 | Copyright (c) 2016 - forever Naufal Rabbani 23 | -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BosNaufal/vue-simple-store/cb1c52ef6ebac7e8ca12f9e9064c353207022ba3/img/logo.png -------------------------------------------------------------------------------- /vue-simple-store.js: -------------------------------------------------------------------------------- 1 | /*! Copyright (c) 2016 Naufal Rabbani (http://github.com/BosNaufal) 2 | * Licensed Under MIT (http://opensource.org/licenses/MIT) 3 | * 4 | * Vue Simple Store - version@1.0.0 5 | * 6 | */ 7 | 8 | (function () { 9 | 10 | var VueSimpleStore = { 11 | 12 | install: function(Vue, opt){ 13 | 14 | var plugin = this; 15 | 16 | if(opt.debug) console.info('[Vue Simple Store]: In Debug Mode'); 17 | 18 | var theStores = {} 19 | var theState = {} 20 | 21 | for (var i = 0; i < opt.stores.length; i++) { 22 | 23 | if(opt.stores[i].name === undefined) console.warn("[Vue Simple Store]: Please add a Store Name", opt.stores[i]); 24 | 25 | // Make a global Stores 26 | theStores[opt.stores[i].name] = opt.stores[i]; 27 | 28 | // Make a global state 29 | if(opt.stores[i].state !== undefined) theState[opt.stores[i].name] = opt.stores[i].state; 30 | 31 | // Remove the name 32 | delete theStores[opt.stores[i].name].name; 33 | } 34 | 35 | plugin.mixin = {}; 36 | 37 | plugin.mixin.init = function(){ 38 | Vue.util.defineReactive(this,'state',theState); 39 | Vue.util.defineReactive(this,'$action', function(eventName,val){ 40 | 41 | var theColon = eventName.search(':'); 42 | var storeName = eventName.substr(0,theColon); 43 | var theEvent = eventName.substr(theColon+1,eventName.length) 44 | 45 | if(theStores[storeName] === undefined) return console.warn("[Vue Simple Store]: the "+storeName+" store doesn't exist"); 46 | 47 | // Trigger the store 48 | theStores[storeName][theEvent](val); 49 | 50 | if(opt.debug){ 51 | if(val === undefined) console.info(eventName); 52 | else console.info(eventName,val); 53 | } 54 | 55 | }); 56 | }; 57 | 58 | // Merge mixin to VM via vue options 59 | Vue.options = Vue.util.mergeOptions(Vue.options, plugin.mixin) 60 | } 61 | 62 | }; 63 | 64 | // If support node / ES6 module 65 | if( typeof module === 'object' && module.exports ){ 66 | module.exports = VueSimpleStore 67 | } 68 | // if using require js 69 | else if (typeof define === 'function' && define.amd) { 70 | define( function () { return VueSimpleStore }) 71 | } 72 | // if script loaded by script tag in HTML file 73 | else if (typeof window !== undefined) { 74 | return window.VueSimpleStore = VueSimpleStore 75 | } 76 | 77 | })() 78 | -------------------------------------------------------------------------------- /vue-simple-store.min.js: -------------------------------------------------------------------------------- 1 | /*! Copyright (c) 2016 Naufal Rabbani (http://github.com/BosNaufal) 2 | * Licensed Under MIT (http://opensource.org/licenses/MIT) 3 | * 4 | * Vue Simple Store - version@1.0.0 5 | * 6 | */ 7 | (function(){var d={install:function(c,b){b.debug&&console.info("[Vue Simple Store]: In Debug Mode");for(var e={},d={},a=0;a