Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide convenience functions for navigation #7

Open
SethDavenport opened this issue Feb 28, 2017 · 4 comments
Open

Provide convenience functions for navigation #7

SethDavenport opened this issue Feb 28, 2017 · 4 comments

Comments

@SethDavenport
Copy link
Member

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?

@matusbielik
Copy link

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.

@dagstuan
Copy link
Collaborator

@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 :)

@matusbielik
Copy link

@dagstuan yes, that's how I solved it in the end, I forgot to delete the post. Thanks anyway!

@SethDavenport
Copy link
Member Author

Yeah I'm hoping to get to this soon. Mostly made the issue so I wouldn't forget :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants