Attempt at Twitter stream

This commit is contained in:
Rodrigo Pedroso 2019-06-21 12:21:23 -04:00
commit d545fbe636
3 changed files with 35 additions and 22 deletions

View file

@ -8,6 +8,7 @@ export default function* watcherSaga() {
])
}
// Data worker
function* worker() {
yield takeEvery("DATA_REQUESTED", workerSaga)
}
@ -21,8 +22,15 @@ function* workerSaga() {
}
}
function getData() {
return fetch("https://jsonplaceholder.typicode.com/posts").then(response =>
response.json()
)
}
// Hillary worker
function* workerHillary() {
yield takeEvery("DATA_TRUMP_REQUESTED", workerTrumpSaga)
yield takeEvery("DATA_HILLARY_REQUESTED", workerHillarySaga)
}
function* workerHillarySaga() {
@ -34,8 +42,15 @@ function* workerHillarySaga() {
}
}
function getHillaryData() {
return fetch("http://localhost:3030/api/twitter?hashtag=Hillary%20Clinton").then(response =>
response.json()
)
}
// Trump worker
function* workerTrump() {
yield takeEvery("DATA_HILLARY_REQUESTED", workerHillarySaga)
yield takeEvery("DATA_TRUMP_REQUESTED", workerTrumpSaga)
}
function* workerTrumpSaga() {
@ -47,20 +62,8 @@ function* workerTrumpSaga() {
}
}
function getData() {
return fetch("https://jsonplaceholder.typicode.com/posts").then(response =>
function getTrumpData() {
return fetch("http://localhost:3030/api/twitter?hashtag=Donald%20Trump").then(response =>
response.json()
)
}
function getHillaryData() {
return fetch("http://localhost:3030/api/twitter?hashtag=Hillary%20Clinton").then(res1 =>
res1.json()
)
}
function getTrumpData() {
return fetch("http://localhost:3030/api/twitter?hashtag=Donald%20Trump").then(res1 =>
res1.json()
)
}