Files
freeCodeCamp/common/app/routes/Jobs/flux/Actions.js
Berkeley Martinez 41274fad2d jobs store fetching
2015-07-25 15:42:03 -07:00

28 lines
668 B
JavaScript

import { Actions } from 'thundercats';
import debugFactory from 'debug';
const debug = debugFactory('freecc:jobs:actions');
export default Actions({
setJobs: null,
getJob(id) {
return { id };
},
getJobs(params) {
return { params };
}
})
.refs({ displayName: 'JobActions' })
.init(({ instance: jobActions, args: [services] }) => {
jobActions.getJobs.subscribe(() => {
services.read('job', null, null, (err, jobs) => {
if (err) {
debug('job services experienced an issue', err);
jobActions.setJobs({ jobs: [] });
}
jobActions.setJobs({ jobs });
});
});
return jobActions;
});