router-store
router-store copied to clipboard
Dispatch router event actions
I think this module would be more useful if we would change it in the following way.
- Rename the actions for
go
,replace
etc toTRIGGER_GO
etc. - Dispatch actions for all the router events.
This way we can use the action methods for triggering any router actions. This is an extra way to trigger router methods, you can still use routerLink
and or router.go
etc.
We can use the RouterEvent actions to react to any router event, be it in a reducer, or using @Effect
.
The main intent of this library is to keep your store in sync the Angular Router URL, since its the source of truth as to what's display on the page.
I'll look into adding the router events, but its also easy enough to map the router events into the store without adding them to this package.
Is it even appropriate to wrap/replicate the router.navigate
functionality within this lib? Seems like its just a duplication of effort for very little gain (also thinking about #30). There's nothing wrong with using the Router
API, right?
@milkisevil I'm beginning to think the same thing. I'm currently running into an issue using the module with Nativescript where I need to call .navigate()
on a module RouterExtensions
instead of Router
to support transitions.
Trying to think through how I stick with this pattern of emitting the go
actions to navigate without replacing core functionality in this module and it's looking like it won't be possible.
The actions are provided so that your navigation can flow through your state. Also if you're using the devtools to debug and time travel through the state, those actions with trigger navigation along with your state changes.
There is going to be an update to this library that no longer uses router actions for navigation and takes a different approach to reducing the state during navigation. There will be breaking changes due to these changes. The repo is here for now https://github.com/vsavkin/router-store
@brandonroberts Thanks for the quick response. That's great news!
@brandonroberts so what would we now do in 4.X with router-store where I'm currently migrating but used go/back/forward?