JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.22/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.1.0/vuex.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js"></script>
<div id="app">
<textarea v-model="text" rows="10" cols="40"></textarea>
<pre>{{ text }}</pre>
</div>
JavaScript
const store = new Vuex.Store({
state: {
text: '',
},
mutations: {
updateText(state, text) {
state.text = text;
},
},
});
new Vue({
el: '#app',
store,
computed: {
text: {
get() {
return this.$store.state.text;
},
set: _.throttle(function(text) {
this.$store.commit(`updateText`, text);
}, 2000),
},
},
});