2015-07-24 17:52:07 -07:00
|
|
|
import { Store } from 'thundercats';
|
|
|
|
|
2015-07-29 10:16:48 -07:00
|
|
|
const { createRegistrar, setter, fromMany } = Store;
|
2015-07-24 17:52:07 -07:00
|
|
|
const initValue = {
|
2015-07-29 10:16:48 -07:00
|
|
|
title: 'Learn To Code | Free Code Camp',
|
2015-07-24 17:52:07 -07:00
|
|
|
username: null,
|
|
|
|
picture: null,
|
2015-12-20 19:24:38 -08:00
|
|
|
points: 0,
|
|
|
|
hikesApp: {
|
|
|
|
hikes: [],
|
|
|
|
currentHikes: {}
|
|
|
|
}
|
2015-07-24 17:52:07 -07:00
|
|
|
};
|
|
|
|
|
2015-10-11 15:57:49 -07:00
|
|
|
export default Store({
|
|
|
|
refs: {
|
|
|
|
displayName: 'AppStore',
|
|
|
|
value: initValue
|
|
|
|
},
|
|
|
|
init({ instance: appStore, args: [cat] }) {
|
2015-10-27 23:46:42 -07:00
|
|
|
const { updateRoute, setUser, setTitle } = cat.getActions('appActions');
|
2015-07-24 17:52:07 -07:00
|
|
|
const register = createRegistrar(appStore);
|
2015-12-20 19:24:38 -08:00
|
|
|
let { setHikes } = cat.getActions('hikesActions');
|
2015-07-29 10:16:48 -07:00
|
|
|
|
2015-12-20 19:24:38 -08:00
|
|
|
// app
|
2015-10-27 23:46:42 -07:00
|
|
|
register(setter(fromMany(setUser, setTitle, updateRoute)));
|
2015-07-24 17:52:07 -07:00
|
|
|
|
2015-12-20 19:24:38 -08:00
|
|
|
// hikes
|
|
|
|
register(setHikes);
|
|
|
|
|
2015-07-24 17:52:07 -07:00
|
|
|
return appStore;
|
2015-10-11 15:57:49 -07:00
|
|
|
}
|
|
|
|
});
|