Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Support for additional action arguments #187

Closed
udnisap opened this issue Jan 13, 2016 · 6 comments
Closed

Support for additional action arguments #187

udnisap opened this issue Jan 13, 2016 · 6 comments

Comments

@udnisap
Copy link

udnisap commented Jan 13, 2016

I was using this for a while and thought this might be a quick implementation of router params.
This is just passing the params to the reducer not via URL but via action itself.

at https://github.com/rackt/redux-simple-router/blob/master/src/index.js#L8

if we replace

function transition(method) {
  return arg => ({
    type: TRANSITION,
    method, arg
  })
}

with

function transition(method) {
  return (arg, data) => ({
    type: TRANSITION,
    method, arg, data
  })
}

we can do something link

import { routeActions } from 'redux-simple-router'
routeActions.push('login', 'custom data');
@udnisap
Copy link
Author

udnisap commented Jan 13, 2016

looks like the transition is an internal event. is there a way to add things to location update event?

@udnisap
Copy link
Author

udnisap commented Jan 13, 2016

params passed to transition.push will be the sent to history so we can use router params there.

@timdorr
Copy link
Member

timdorr commented Jan 14, 2016

It might be better like this:

function transition(method) {
  return ...arg => ({
    type: TRANSITION,
    method, args
  })
}

Then you can pass in an unlimited number of arguments, not just 1 or 2.

@timdorr
Copy link
Member

timdorr commented Jan 14, 2016

This would make a great PR! 😉

@timdorr timdorr changed the title Support for route params Support for addition action arguments Jan 14, 2016
@timdorr timdorr changed the title Support for addition action arguments Support for additional action arguments Jan 14, 2016
@udnisap
Copy link
Author

udnisap commented Jan 15, 2016

But TRANSITION events are handled by the reduxRouterMiddleware. Only the UPDATELOCATION is passed to reducer. I was able to do this with
transition('push')({pathname: 'login' , state: somedata}) when dispatching and
action.location.state in reducer

@timdorr
Copy link
Member

timdorr commented Jan 15, 2016

Yes, that is correct. You should use the state property to store extra data about your location.

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

No branches or pull requests

2 participants