File: app/components/test-chat/store/actions.js

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

Contents

Class file image Download
define([ 'app/components/test-chat/api/index', 'app/components/test-chat/store/mutation-types' ], function (api, types) { var getAllMessages = function (store) { api.getAllMessages(function (messages) { store.commit(types.RECEIVE_ALL, messages); }); }; var sendMessage = function (store, message) { api.createMessage(message.text, message.thread, function (message) { store.commit(types.RECEIVE_MESSAGE, message); }); }; var switchThread = function (store, id) { store.commit(types.SWITCH_THREAD, id); }; return { getAllMessages: getAllMessages, sendMessage: sendMessage, switchThread: switchThread }; });