ngworker / router-component-store

A strictly typed lightweight alternative to NgRx Router Store and ActivatedRoute.
MIT License
34 stars 2 forks source link

Add support for custom serializer and custom router state type #260

Open Harpush opened 2 years ago

Harpush commented 2 years ago

The current ngrx router-store supports provofing a custom state serializer and working with a custom state type. router-component-store should support this too.

Funding

Fund with Polar

LayZeeDK commented 2 years ago

Thank you for your feature request. What's a use case for this?

Harpush commented 2 years ago

Currently the used serializer is always MinimalRouterStateSerializer. Sometimes you wish to provide your own serializer as seen in the official router store. Mostly for custom route data aggregations.

LayZeeDK commented 2 years ago

I'm not very familiar with @ngrx/router-store but from what I can read, a router state serializer is used to extract more slices of state from RouterStateSnapshot, correct?

Harpush commented 2 years ago

Indeed. It's used to allow the user to add more or less state slices to the router state. It can be used to aggreagte data across the route tree and omit unwnated data.

LayZeeDK commented 2 years ago

I'm not sure how adding this is better than subscribing to the RouterState through the Router and mapping using observable operators. That seems to be a lot easier than implementing a router serializer.

In NgRx RouterStore this functionality was added to support Redux Dev Tools. Currently, NgRx ComponentStore doesn't have native support for Redux Dev Tools.

LayZeeDK commented 2 years ago

Even if we were to add it, I worry it would increase the bundle size significantly even for the xx% of applications never using this feature.