Status of Redux and Angular 2 Routing

I am trying to understand Redux state management in my Angular 2 application, and I am wondering how to use Redux mode and Angular 2 routing.

For example, I have different kinds (for example, components with separate routes) that take a date or a date range. Thus, in my application panel, I got a button that displays a calendar for the user to select a date. The view then receives this date as a request parameter,

http://localhost:3000/view&date=20160928

Then I can get the date inside the component by listening to the parameters of the activated routing request

this.route.queryParams.subscribe(params => <load records for date>);

Now, how can I do this using Redux, that is, how should I only store state in the Redux store? At first it seemed to me that I just get the date parameter and send it as DATE_ACTION_CHANGEto the repository, and then, in turn, it will listen to the state change

date$ = this.ngRedux.select(state => state.date)
   .subscribe(date => <load records for date>);

Is this the recommended way to do this? It works fine as long as I only have one observable. However, I get the parameters from different sources. For example, the client identifier will be another parameter. This, in turn, is part of the URL,

localhost:3000//client/45&date=20160928

That is, when it becomes foggy, should the repository with the identifier and date be updated, and then listen to changes in both properties in state? What if someone changes and the other doesn't? I feel like I'm doing it wrong, any pointers?

+4
1

, :

https://github.com/ngrx/router-store ( , ngrx/store).

angular/router ngrx/store. :

  store.dispatch(go(['/path', { routeParam: 1 }], { query: 'string' }));

  store.dispatch(replace(['/path'], { query: 'string' }));

  store.dispatch(show(['/path'], { query: 'string' }));

  store.dispatch(search({ query: 'string' }));

  store.dispatch(back());

  store.dispatch(forward());

: https://github.com/dagstuan/ng2-redux-router

+4

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


All Articles