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: [],
|
2015-12-29 17:35:50 -08:00
|
|
|
// lecture state
|
|
|
|
currentHike: {},
|
2015-12-26 00:42:39 -08:00
|
|
|
showQuestion: false
|
2015-12-20 19:24:38 -08:00
|
|
|
}
|
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-12-22 19:33:25 -08:00
|
|
|
const { updateRoute, getUser, setTitle } = cat.getActions('appActions');
|
2015-07-24 17:52:07 -07:00
|
|
|
const register = createRegistrar(appStore);
|
2015-12-29 17:35:50 -08:00
|
|
|
const {
|
|
|
|
toggleQuestions,
|
|
|
|
fetchHikes,
|
|
|
|
hideInfo,
|
|
|
|
grabQuestion,
|
|
|
|
releaseQuestion,
|
|
|
|
moveQuestion,
|
|
|
|
answer
|
|
|
|
} = cat.getActions('hikesActions');
|
2015-07-29 10:16:48 -07:00
|
|
|
|
2015-12-20 19:24:38 -08:00
|
|
|
// app
|
2015-12-22 19:33:25 -08:00
|
|
|
register(setter(fromMany(getUser, setTitle, updateRoute)));
|
2015-07-24 17:52:07 -07:00
|
|
|
|
2015-12-20 19:24:38 -08:00
|
|
|
// hikes
|
2015-12-29 17:35:50 -08:00
|
|
|
register(
|
|
|
|
fromMany(
|
|
|
|
toggleQuestions,
|
|
|
|
fetchHikes,
|
|
|
|
hideInfo,
|
|
|
|
grabQuestion,
|
|
|
|
releaseQuestion,
|
|
|
|
moveQuestion,
|
|
|
|
answer
|
|
|
|
)
|
|
|
|
);
|
2015-12-20 19:24:38 -08:00
|
|
|
|
2015-07-24 17:52:07 -07:00
|
|
|
return appStore;
|
2015-10-11 15:57:49 -07:00
|
|
|
}
|
|
|
|
});
|