can you please tell me how to fetch data from server first time only and show to screen . but if user come again or if component again loaded it get data from store .I am using redux with ngrx .
I made a sample application in which i have two button home screen
and new screen
home screen I show list which is coming from server
.when i click new screen
button and come back to home screen it again it server and get the data.I don't want to hit again.I want to get data from store
.How i will get it
here is my code
(don't open this link in chrome stackblitz have issue in chrome )
export class ListComponent implements OnInit {
products$: Observable<Product[]>;
constructor(private productService: ProductService,
private store: Store<fromApp.ProductState>,
private router : Router
) {}
ngOnInit() {
this.store.dispatch(new productActions.Load());
this.products$ = this.store.pipe(select(fromProduct.getProducts))
}
}