Skip to content

Query return extended observable directly #27

Answered by NetanelBasal
anymaniax asked this question in Q&A
Discussion options

You must be logged in to vote

@anymaniax I have come up with this solution:

export class PaginationService {
  private useQuery = inject(QueryProvider);

  getProjects = inject(PersistedQuery).use((key: ['projects', number]) => {
    return this.useQuery(key, ({ queryKey }) => fetchProjects(queryKey[1]), {
      staleTime: 5000,
      keepPreviousData: true,
    });
  });
}
  projects$ = this.page$.pipe(
    switchMap((page) => {
      return this.projectsService.getProjects(['projects', page]).result$
    })
  );

Replies: 10 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@NetanelBasal
Comment options

@anymaniax
Comment options

@NetanelBasal
Comment options

@anymaniax
Comment options

@NetanelBasal
Comment options

Comment options

You must be logged in to vote
4 replies
@NetanelBasal
Comment options

@anymaniax
Comment options

@anymaniax
Comment options

Answer selected by anymaniax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #25 on October 16, 2022 09:15.