2015-07-25 13:58:26 -07:00
|
|
|
import { Actions } from 'thundercats';
|
2015-07-25 15:42:03 -07:00
|
|
|
import debugFactory from 'debug';
|
|
|
|
|
|
|
|
const debug = debugFactory('freecc:jobs:actions');
|
2015-07-25 13:58:26 -07:00
|
|
|
|
|
|
|
export default Actions({
|
2015-07-25 15:42:03 -07:00
|
|
|
setJobs: null,
|
2015-07-25 13:58:26 -07:00
|
|
|
getJob(id) {
|
|
|
|
return { id };
|
|
|
|
},
|
|
|
|
getJobs(params) {
|
|
|
|
return { params };
|
|
|
|
}
|
|
|
|
})
|
2015-07-25 15:42:03 -07:00
|
|
|
.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;
|
|
|
|
});
|