Icontem

File: app/components/test-counter-hot/store/actions.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy  >  Vuex Examples  >  app/components/test-counter-hot/store/actions.js  >  Download  
File: app/components/test-counter-hot/store/actions.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Vuex Examples
Example apps using Vuex state management pattern
Author: By
Last change: Compatibility wthis IE
Date: 2 years ago
Size: 749 bytes
 

Contents

Class file image Download
define(['es6_promise'], function (ES6Promise) {
    var actions = {
        increment: function (context) {
            return context.commit('increment');
        },
        decrement: function (context) {
            context.commit('decrement');
        },
        incrementIfOdd: function (context) {
            if ((context.state.count + 1) % 2 === 0) {
                context.commit('increment');
            }
        },
        incrementAsync: function (context) {
            return new ES6Promise.Promise(function (resolve, reject) {
                setTimeout(function () {
                    context.commit('increment');
                    resolve();
                }, 1000);
            });
        }
    };
    return actions;
});