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

Dispatch router event actions

Open marklagendijk opened this issue 8 years ago • 6 comments

I think this module would be more useful if we would change it in the following way.

  1. Rename the actions for go, replace etc to TRIGGER_GO etc.
  2. 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.

marklagendijk avatar Jan 09 '17 18:01 marklagendijk

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.

brandonroberts avatar Feb 02 '17 22:02 brandonroberts

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?

philipbulley avatar Feb 08 '17 17:02 philipbulley

@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.

llwt avatar Mar 15 '17 01:03 llwt

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 avatar Mar 15 '17 01:03 brandonroberts

@brandonroberts Thanks for the quick response. That's great news!

llwt avatar Mar 15 '17 01:03 llwt

@brandonroberts so what would we now do in 4.X with router-store where I'm currently migrating but used go/back/forward?

pjmagee avatar Jul 24 '17 09:07 pjmagee