forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Berkeley Martinez
authored and
Berkeley Martinez
committed
Jul 25, 2015
1 parent
a45863c
commit 41274fa
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
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: 'JobsActions' }); | ||
.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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { Store } from 'thundercats'; | ||
|
||
const { setter } = Store; | ||
|
||
export default Store() | ||
.refs({ displayName: 'JobsStore' }) | ||
.init(({ instance: jobsStore, args: [cat] }) => { | ||
let jobsActions = cat.getActions('JobsActions'); | ||
jobsStore.register(jobsActions.getJob); | ||
let jobActions = cat.getActions('JobActions'); | ||
jobsStore.register(setter(jobActions.setJobs)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import Fetchr from 'fetchr'; | ||
import getHikesService from '../services/hikes'; | ||
import getJobServices from '../services/job'; | ||
import getUserServices from '../services/user'; | ||
|
||
export default function bootServices(app) { | ||
const hikesService = getHikesService(app); | ||
const jobServices = getJobServices(app); | ||
const userServices = getUserServices(app); | ||
|
||
Fetchr.registerFetcher(hikesService); | ||
Fetchr.registerFetcher(jobServices); | ||
Fetchr.registerFetcher(userServices); | ||
app.use('/services', Fetchr.middleware()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default function getJobServices(app) { | ||
const { Job } = app.models; | ||
|
||
return { | ||
name: 'job', | ||
read: (req, resource, params, config, cb) => { | ||
Job.find({}, (err, jobs) => { | ||
cb(err, jobs); | ||
}); | ||
} | ||
}; | ||
} |