Open SethDavenport opened 7 years ago
I am just dealing with this, does anyone know how to handle navigation with ng2-redux (and its router)?
When I try to dispatch UPDATE_LOCATION
event that is used by this library, I get error: Unhandled Promise rejection: action$.ofType(...).mapTo is not a function
and the stack trace is really unclear.
This is how I use it:
// after succesfully adding new post, I want navigate to home
createPostSucceeded = action$ => action$
.ofType(PostsActions.CREATE_POST_SUCCEEDED)
.mapTo({ type: '@angular-redux/router::UPDATE_LOCATION', payload: ''});
To me, it really looks like one of the epics from redux-observables tutorial:
pingEpic = action$ => action$
.ofType('PING')
.delay(1000) // Asynchronously wait 1000ms then continue
.mapTo({ type: 'PONG' });
Anyway, I don't know how to route at all when using epics, so any advice is appreciated. Seeing this legit question unanswered for 13 days now makes me worried.
@SethDavenport sure, this is a good idea. However I dont currently have time to fix it, so feel free to submit a PR if you need it :)
@wewo given your code I'm not exactly sure what your problem is. I havent used this library with epics. I normally just inject the router into the action creators and do routing directly instead of via ng2-redux. I made this library just because I needed the functionality at the time, but I currently dont have time to add new functionality. If you see something you need, feel free to submit a PR :)
@dagstuan yes, that's how I solved it in the end, I forgot to delete the post. Thanks anyway!
Yeah I'm hoping to get to this soon. Mostly made the issue so I wouldn't forget :)
react-router-redux exposes functions, put, replace, etc. that dispatch navigation actions. This allows for navigation by dispatch, which is especially handy for things like epics. Would we be able to do something similar here?