Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- concat( throwError('Retry limit exceeded!'))
- initFeeds() {
- let tempObs = combineLatest(this.search$, this.source$)
- this.feeds$ = tempObs.pipe(debounceTime(0), tap(x => console.log('query update')), switchMap(([search, source]: any) => {
- this.searchString = search
- this.sourceString = source
- let query$;
- if (search.length === 0) {
- query$ = this.db.collection(`feeds`, ref => ref
- .where('sources', 'array-contains', source)
- .where('groupId', '==', environment.groupId)
- .orderBy('publishedDate', 'desc')).snapshotChanges()
- }
- else {
- query$ = this.db.collection('feeds', ref => ref
- .where('groupId', '==', environment.groupId)
- .where('titleSearchArray', 'array-contains', search.toLowerCase())
- .orderBy('title', 'asc')
- .orderBy('publishedDate', 'desc')).snapshotChanges()
- }
- return query$.pipe(
- timeout(50),
- retryWhen(
- errors => errors.pipe(
- delay(500),
- tap(() => console.log(`trying to fetch data`)),
- take(2),
- concat(
- throwError('Retry limit exceeded!')
- )
- )
- ),
- finalize(() => {
- this.loadingPrvd.dismissLoader()
- }),
- catchError(() => throwError('Retry Failed')),
- )
- }))
- this._feedsSub = this.feeds$.pipe().subscribe(
- (data: any[]) => {
- console.log('success')
- },
- (err: any) => {
- console.error('An error occured!', err)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement