-
Notifications
You must be signed in to change notification settings - Fork 14
Hw5 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hw5 #28
Conversation
| * Не понимаю, почему следующие две строчки срабатывают только один раз | ||
| * если yield spawn(realtimePeopleSyncSaga) | ||
| * */ | ||
| const {payload} = yield take('@@router/LOCATION_CHANGE') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше использовать {LOCATION_CHANGE} from 'react-router-redux'
| /* Вопрос: | ||
| * Не понимаю, почему следующие две строчки срабатывают только один раз | ||
| * если yield spawn(realtimePeopleSyncSaga) | ||
| * */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну ты ведь каждый раз ждешь изменения роута
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
смотри, у меня есть сага realtimePeopleSyncSaga.
Внутри неё я хочу ловить событие смены урла, и использовать возвращаемое yield-ом значение payload:
export const realtimePeopleSyncSaga = function * () {
const chan = yield call(createPeopleSocket)
while (true) {
/* вот тут хочу получать данные и реагировать на них */
const {payload} = yield take(LOCATION_CHANGE)
console.log('---payload: ', payload);
}
}И я её вызываю в главной саге утки:
export function * saga() {
yield spawn(realtimePeopleSyncSaga)
// yield spawn(cancelableRealtimePeopleSyncSaga)
yield all([
takeEvery(ADD_PERSON_REQUEST, addPersonSaga),
takeEvery(ADD_EVENT_REQUEST, addEventToPersonSaga)
])
}По идее, теперь при каждом переходе (на админа или события, должно происходить событие смены урла и выводится payload). Событие происходит, но не отрабатывает console!
И вот это я не понимаю.
Задание сделал: через создание ещё одной саги cancelableRealtimeSyncSaga, которую отменяю и в отмененной саге (realtimePeopleSyncSaga) уже отключаю канал в finally.
Но первая мысль была сразу обрабатывать смену урла в realtimePeopleSyncSaga и отключать канал.
И не пойму, почему именно она не работает. Событие смены происходит, а реакции ноль
No description provided.