ngRx 4 router-store router serializer

403 views Asked by At

When using the router-store from ngRx 4 and the router serializer, should we continue to use the built-in router's ActivatedRouterSnapshot for situations like the following (pulling a token off a router parameter inside a component):

constructor(
    private appMessengerService: AppMessengerService,
    private authenticationStore: Store<authenticationStorePlan.State>,
    private route: ActivatedRoute
  ) {
    this.appMessengerService.subscribeToMessenger()
  }

  ngOnInit() {
    const token = this.route.snapshot.paramMap.get('token')
    this.validateToken(token)
  }

The router serializer shows an example of the root level query params, but in this situation, my component is a child of the root and it seems like a hairy situation to try picking off the exact branches of children for these params instead of just taking them from the component's activated route injection.

I'm trying to make the store the single-source of truth, but it feels hacky be setting the router state slice with the router serializer.

Is there a good way to set up the router serializer to do something similar to the Angular router for params without making the router state object too big for the dev tools ?

0

There are 0 answers