Conversation
```
import createRouter, { redirect } from '@density/conduit';
const router = createRouter(store);
router.addRoute('foo/bar', redirect('hello/world'))
router.addRoute('hello/world', () => ({type: "NAVIGATE_TO_HELLO_WORLD"}) )
```
guscost
left a comment
There was a problem hiding this comment.
Looks good but the documentation probably has an error.
| import store from './store'; | ||
|
|
||
| const router = createRouter(store); | ||
| router.addRoute('foo/bar', redirect('hello/world')); |
There was a problem hiding this comment.
Is this being imported directly from the conduit package? Should probably document that if so.
|
RE: side-effect-only action creator: I'd suggest that this shouldn't be used for hash routes, the normal router Considering that redirects would/should be going to entirely different web apps, the side effect is really "finish interacting with the app" as far as the app itself is concerned. |
|
In one way that the dashboard currently uses this functionality, it's going to a different route in the dashboard, not to an external app: https://github.com/DensityCo/dashboard/blob/trunk/src/index.js#L137 But other than for deprecated routes like that (and we probably can get rid of that line now anyway) I agree. |
|
Why can't that be |
|
Because that function returns |
|
Ah, makes sense. |
Add a helper that can be used for redirecting to a different route.
The dashboard uses a pattern similar to this already, though I'm not completely sold on it since this change effectively adds the ability for an action creator that returns nothing (like the
redirectaction creator) to be a side-effect only action creator and I'm not sure if that's starting down a path of making this project too all-encompassing.