Additional routers with @ngrx

Like ngrx / example-app, I create an interface in which users can search for something by entering a text string.

I would like to update the url with an optional parameter ( query=search_string ), so that when the user returns to their search using the back button, they will return to the same already loaded search. (I will do the same for the page on which they are located)

What would be the appropriate way to add optional parameters using ngrx?

My thought is to put this in BookEffects , since we don’t want to update the route before debugging time. But for some reason this does not seem right ...

[Change] To continue further when the user goes to the search page, the search needs to be recharged somehow. Therefore, I also thought about modifying FindBookPageComponent to include:

 constructor(..., private route: ActivatedRoute) { ... } ngOnInit() { let query = this.route.snapshot.params['query']; if (query) { this.store.dispatch(new book.SearchAction(query)); } } 

This still seems inconvenient because there will be an unnatural delay before the search results appear due to debounce in SearchAction . This means that we must also create a separate search action: ImmediateSearchAction ?

+5
source share

Source: https://habr.com/ru/post/1265351/


All Articles