Instantly share code, notes, and snippets.


a cool Vuex trick:

Ever find yourself spending the time to write a separate mutation every time you want to save some data in your Vuex store? And you end up with dozens, or even hundreds of lines of mutations to scroll through?

Stop the boilerplate!

Add this function to your mutations object and you'll never have to write a simple mutation again! (Unless your mutation needs to do more than just save data to the store)

storeIt(state, obj) {
    switch (typeof obj.value) {
        case 'string':
View sampledata.json
"eventType": "sessionInfo",
"userType": "premium",
"sessionGroup": 1
"eventType": "mediaPlay",
"productSKU": "starwars",
"sessionGroup": 1,
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View designer.html
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<polymer-element name="my-element">