vue-global-state
v1.0.1
Published
Vue global state manger
Downloads
12
Readme
VUE GLOBAL STATE
VUE GLOBAL STATE MANAGER helps you to manage your global state easier without any additional dependencies
- Manage global state
- Add event listeners
- Save data
Current features
addListener(id:String, cb:function):undefined
on(id:String, cb:function):undefined [synonim for addListener]
once(id:String, cb:function):undefined
removeListener(id:String, cb:function):undefined
removeAll(id:String):undefined
getListener(id:String):Array
getCount(id:String):Number
emit(id:String,[data:any]):undefined
setData(id:String,[data:any]) :undefined [triger 'update' listener]
getData(id:String):any
getAllData():Object
removeData(id:String):any
Example
init
import GAS from 'vue-global-state'
const GAS = reuqire('vue-global-state');
listeners
GAS.addListener('event',cb);
GAS.emit('event',data);
GAS.on('update',handleData);
data
GAS.setData('user',{username:"Pr0xY"}); // trigers update listener
GAS.getData('user') // return {username: "Pr0xY"}
GAS.getAllData() // return {user:{username: "Pr0xY" }}
GAS.removeData('user') // removes user from object and return it