Similar to the ngrx/example-app, I am building an interface where users will be able to search for something by entering a text string.
I would like to update the url with an optional param (query=search_string
) so that when the user returns to their search with the back button they return to the same search already loaded. (I'll also be doing the same thing for the page they are on)
What would be the appropriate way to add optional params with ngrx?
My thought is to put this into BookEffects
since we do not want to update the route prior to the debounce time. But for some reason that doesn't feel right...
[Edit]
To expand on this further, when the user navigates back to the search page, the search would need to be bootstrapped somehow. So my thought would be to also modify the 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 feels awkward because there would be an unnatural delay before the search results appear due to the debounce
in the SearchAction
. So does this mean we should also create a separate search action: ImmediateSearchAction
?