router-component-store icon indicating copy to clipboard operation
router-component-store copied to clipboard

Add support for custom serializer and custom router state type

Open Harpush opened this issue 2 years ago • 6 comments

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

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive 90% of the pledge once the issue is completed & verified
  • Polar receives 10% of the pledge as a fee
Fund with Polar

Harpush avatar Jun 18 '22 18:06 Harpush

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

LayZeeDK avatar Jun 18 '22 21:06 LayZeeDK

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.

Harpush avatar Jun 18 '22 21:06 Harpush

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?

LayZeeDK avatar Jun 20 '22 14:06 LayZeeDK

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.

Harpush avatar Jun 20 '22 15:06 Harpush

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 avatar Jun 21 '22 19:06 LayZeeDK

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.

LayZeeDK avatar Jun 21 '22 20:06 LayZeeDK