Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. concat( throwError('Retry limit exceeded!'))
  2.  
  3. initFeeds() {
  4.  
  5. let tempObs = combineLatest(this.search$, this.source$)
  6. this.feeds$ = tempObs.pipe(debounceTime(0), tap(x => console.log('query update')), switchMap(([search, source]: any) => {
  7. this.searchString = search
  8. this.sourceString = source
  9. let query$;
  10. if (search.length === 0) {
  11. query$ = this.db.collection(`feeds`, ref => ref
  12. .where('sources', 'array-contains', source)
  13. .where('groupId', '==', environment.groupId)
  14. .orderBy('publishedDate', 'desc')).snapshotChanges()
  15. }
  16. else {
  17. query$ = this.db.collection('feeds', ref => ref
  18. .where('groupId', '==', environment.groupId)
  19. .where('titleSearchArray', 'array-contains', search.toLowerCase())
  20. .orderBy('title', 'asc')
  21. .orderBy('publishedDate', 'desc')).snapshotChanges()
  22. }
  23. return query$.pipe(
  24. timeout(50),
  25. retryWhen(
  26. errors => errors.pipe(
  27. delay(500),
  28. tap(() => console.log(`trying to fetch data`)),
  29. take(2),
  30. concat(
  31. throwError('Retry limit exceeded!')
  32. )
  33. )
  34. ),
  35. finalize(() => {
  36. this.loadingPrvd.dismissLoader()
  37. }),
  38. catchError(() => throwError('Retry Failed')),
  39.  
  40. )
  41. }))
  42.  
  43. this._feedsSub = this.feeds$.pipe().subscribe(
  44. (data: any[]) => {
  45. console.log('success')
  46. },
  47. (err: any) => {
  48. console.error('An error occured!', err)
  49. })
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement