Files
freeCodeCamp/common/app/flux/Store.js

34 lines
724 B
JavaScript
Raw Normal View History

import { Store } from 'thundercats';
const { createRegistrar, setter, fromMany } = Store;
const initValue = {
title: 'Learn To Code | Free Code Camp',
username: null,
picture: null,
2015-12-20 19:24:38 -08:00
points: 0,
hikesApp: {
hikes: [],
currentHikes: {}
}
};
export default Store({
refs: {
displayName: 'AppStore',
value: initValue
},
init({ instance: appStore, args: [cat] }) {
2015-12-22 19:33:25 -08:00
const { updateRoute, getUser, setTitle } = cat.getActions('appActions');
const register = createRegistrar(appStore);
2015-12-22 19:33:25 -08:00
const { fetchHikes } = cat.getActions('hikesActions');
2015-12-20 19:24:38 -08:00
// app
2015-12-22 19:33:25 -08:00
register(setter(fromMany(getUser, setTitle, updateRoute)));
2015-12-20 19:24:38 -08:00
// hikes
2015-12-22 19:33:25 -08:00
register(fetchHikes);
2015-12-20 19:24:38 -08:00
return appStore;
}
});