habitica-self-host/website/client/store/index.js

25 lines
911 B
JavaScript
Raw Normal View History

import Store from 'client/libs/store';
import deepFreeze from 'client/libs/deepFreeze';
import content from 'common/script/content/index';
import { asyncResourceFactory } from 'client/libs/asyncResource';
2016-12-07 01:11:40 +00:00
import actions from './actions';
import getters from './getters';
2016-12-06 21:17:23 +00:00
// Export a function that generates the store and not the store directly
// so that we can regenerate it multiple times for testing
export default function () {
return new Store({
actions,
getters,
state: {
title: 'Habitica',
user: asyncResourceFactory(),
tasks: asyncResourceFactory(), // user tasks
// content data, frozen to prevent Vue from modifying it since it's static and never changes
// TODO apply freezing to the entire codebase (the server) and not only to the client side?
// NOTE this takes about 10-15ms on a fast computer
content: deepFreeze(content),
},
2016-12-06 21:17:23 +00:00
});
}