Icontem

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

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy  >  Vuex Examples  >  app/components/test-chat/store/getters.js  >  Download  
File: app/components/test-chat/store/getters.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:
Date: 2 years ago
Size: 644 bytes
 

Contents

Class file image Download
define([], function () {

    var threads = function (state) {
        return state.threads;
    };
    var currentThread = function (state) {
        var thread = state.currentThreadID ? state.threads[state.currentThreadID] : {};
        return thread;
    };
    var currentMessages = function (state) {
        var thread = currentThread(state);
        var messages = thread.messages ? thread.messages.map(function (id) {
            return state.messages[id];
        }) : [];
        return messages;
    };
    return {
        threads: threads,
        currentThread: currentThread,
        currentMessages: currentMessages
    };
});