vue-blick
Super Simple State Management
Installation
npm install vue-blick
Usage
- Create your store
// store/alert-store.js message: 'Hello' // state { // computed fields/getters return thismessage } async { // methods/actions // await fetch(...) thismessage = message }
- Inside any component
<template> <div>alert: {{ message }}</div> <div>reversed alert: {{ reversedMessage }}</div> <button @click="setMessage('World')">alert!</button></template> <script>import alertStore from './store/alert-store' export default { mixins: [ alertStore.map('message', 'reversedMessage', 'setMessage') ]}</script>
Outside of vue templates
You can also access the raw observable state through store.state
. Maybe you want to call a method from one store to another.