Skip to content

Commit

Permalink
feat(): Init job object
Browse files Browse the repository at this point in the history
  • Loading branch information
abalone0204 committed Sep 13, 2016
1 parent 119f514 commit e05d65c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 15 deletions.
37 changes: 37 additions & 0 deletions front-end/app/sagas/fetchInitJobObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
takeEvery
} from 'redux-saga'

import {
put,
call
} from 'redux-saga/effects'

import {
FETCH_INIT_JOB_OBJECT,
setInitJobObject,
failToInitJobObject,
} from 'actions/initialize.js'

import getProvider, {
getProviderName,
getJobQuery
} from '../providers'



export function* watchFetchInitJobObject() {
yield call(takeEvery, FETCH_INIT_JOB_OBJECT, initJobObjectFlow)
}

export function* initJobObjectFlow(action) {
try {
const providerName = yield call(getProviderName)
const provider = yield call(getProvider)
const jobObject = yield call(getJobQuery, provider)
yield put(setInitJobObject(jobObject))

} catch (error) {
yield put(failToInitJobObject(error))
}
}
49 changes: 34 additions & 15 deletions front-end/app/sagas/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
import {watchRequestLogin} from './login.js'
import {watchRequestLeaveComment} from './leaveComment.js'
import {watchRequestFetchComments} from './fetchComments.js'
import {watchRequestFetchJob} from './fetchJob.js'
import {watchRequestCreateJob} from './createJob.js'
import {
transactionOfJobAndComments
watchRequestLogin
} from './login.js'
import {
watchRequestLeaveComment
} from './leaveComment.js'
import {
watchRequestFetchComments
} from './fetchComments.js'
import {
watchRequestFetchJob
} from './fetchJob.js'
import {
watchRequestCreateJob
} from './createJob.js'
import {
transactionOfJobAndComments
} from './transactionFlows.js'
import {
watchRequestFetchWorkingTimes,
} from './fetchWorkingTimes.js'

import {
watchFetchInitJobObject,
} from './fetchInitJobObject.js'

export default function* rootSaga() {
yield [
watchRequestLogin(),
watchRequestLeaveComment(),
watchRequestFetchComments(),
watchRequestFetchJob(),
watchRequestCreateJob(),
transactionOfJobAndComments()
]
}
yield [
watchRequestLogin(),
watchRequestLeaveComment(),
watchRequestFetchComments(),
watchRequestFetchJob(),
watchRequestCreateJob(),
transactionOfJobAndComments(),
watchRequestFetchWorkingTimes(),
watchFetchInitJobObject(),
]
}

0 comments on commit e05d65c

Please sign in to comment.