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

104 lines
1.7 KiB
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: [],
2015-12-29 17:35:50 -08:00
// lecture state
currentHike: {},
showQuestions: false
2016-01-04 14:26:07 -08:00
},
jobsApp: {
showModal: false
2015-12-20 19:24:38 -08:00
}
};
export default Store({
refs: {
displayName: 'AppStore',
value: initValue
},
2016-01-04 14:26:07 -08:00
init({ instance: store, args: [cat] }) {
const register = createRegistrar(store);
// app
2015-12-31 17:39:29 -08:00
const {
updateLocation,
getUser,
2016-01-07 14:51:41 -08:00
setTitle,
toast
2015-12-31 17:39:29 -08:00
} = cat.getActions('appActions');
register(
fromMany(
setter(
fromMany(
getUser,
setTitle
)
),
2016-01-07 14:51:41 -08:00
updateLocation,
toast
2015-12-31 17:39:29 -08:00
)
);
2015-12-20 19:24:38 -08:00
// hikes
2016-01-04 14:26:07 -08:00
const {
toggleQuestions,
fetchHikes,
2016-01-06 15:39:41 -08:00
resetHike,
2016-01-04 14:26:07 -08:00
grabQuestion,
releaseQuestion,
moveQuestion,
answer
} = cat.getActions('hikesActions');
2015-12-29 17:35:50 -08:00
register(
fromMany(
toggleQuestions,
fetchHikes,
2016-01-06 15:39:41 -08:00
resetHike,
2015-12-29 17:35:50 -08:00
grabQuestion,
releaseQuestion,
moveQuestion,
answer
)
);
2015-12-20 19:24:38 -08:00
2016-01-04 14:26:07 -08:00
// jobs
const {
findJob,
saveJobToDb,
getJob,
getJobs,
openModal,
closeModal,
handleForm,
getSavedForm,
setPromoCode,
applyCode,
clearPromo
} = cat.getActions('JobActions');
register(
fromMany(
findJob,
saveJobToDb,
getJob,
getJobs,
openModal,
closeModal,
handleForm,
getSavedForm,
setPromoCode,
applyCode,
clearPromo
)
);
}
});