I have a resolver on one of my routes in order to allow it to get data before the page actually loads. This required multiple requests therefore I am using rxjs function forkJoin. This returns the data great and the page doesn't load until all of the data is fully loaded, which is exactly how I want.
However, the data that is gets is pretty hefty meaning it can take a while before the route loads. I want to somehow, still resolve this route but then cache it and let the component know that this is cached.
I rely on the data coming back from the activatedRoute within the component as the page needs this. So I need it to stop overriding what is currently there as well.
This is my code so far:
Resolver:
const postId: string = this.postService.data.post.id;
const authorData$: Observable<HttpResponse<any>> = this.authorService.getAuthor();
const commentsData$: Observable<HttpResponse<any>> = this.commentsService.getComments();
I understand that this can be done in one request but this is just an example of what I would be using it for. So I don't want a suggestion that says put it in one request.
this.activatedRoute.data.subscribe((data) => {
this.author = data[0][0];
this.comments = data[0][1].data;
});
So I want to do this only on the first load of the component.
Thanks in advance.