index.js 1.1 KB

123456789101112131415161718192021222324252627
  1. import { all, put,take, fork, takeEvery, takeLatest, takeLeading, select,call, join } from 'redux-saga/effects'; //
  2. import { promiseWorker } from '../promise';
  3. import {actionExplorePostsCount,actionExplorePosts } from '../../../actions/query/exploreQuery'
  4. import { actionExploreType } from '../../../actions/types/exploreTypes'
  5. function* exploreWorker() {
  6. const {
  7. explore: { explorePosts, explorePostsCount },
  8. } = yield select()
  9. console.log('explorePosts', explorePosts)
  10. if (explorePosts?.length !== (explorePostsCount ? explorePostsCount : 1)) {
  11. console.log('explorePosts', explorePosts)
  12. const newPosts = yield call(promiseWorker,
  13. actionExplorePosts(explorePosts?.length))
  14. console.log('newPosts', newPosts)
  15. const newPostsExploreCount = yield call(promiseWorker, (actionExplorePostsCount()))
  16. if (newPosts && newPostsExploreCount)
  17. yield put(actionExploreType(newPosts, newPostsExploreCount))
  18. }
  19. }
  20. export function* exploreWatcher() {
  21. yield takeLeading("EXPLORE_POSTS", exploreWorker)
  22. }