redux-ui-router icon indicating copy to clipboard operation
redux-ui-router copied to clipboard

Add ability to import the constants of the action-types

Open ondrasak opened this issue 7 years ago • 6 comments

Would be great to have ability to import the constants of the action-types .

Use case: I want to listen on some action and perform side-effect now I need to hardcode the name of the action

ondrasak avatar May 17 '17 06:05 ondrasak

@ondrasak I'm not sure that I fully understand your proposal. Could explain it in a bit more detail?

hally9k avatar May 17 '17 07:05 hally9k

let say I want the behaviour: When route/state is changed -> close side navigation

so in some redux-middleware (i my case redux-observable) -> I will check all action if their type is equal to '@@reduxUiRouter/$stateChangeStart' -> if YES then perform desired action

so I need to get somehow the string "@@reduxUiRouter/$stateChangeStart"

would be great to have ability to import that constant

import {STATE_CHANGE_START} from "redux-ui-router"
// or
import {actionTypes} from "redux-ui-router" // -> actionTypes.STATE_CHANGE_START

ondrasak avatar May 17 '17 10:05 ondrasak

I understand now. As opposed to maintaining those constants externally. I may get round to this in a week or so but open to a PR in the meantime 👍

hally9k avatar May 20 '17 22:05 hally9k

Yes, agreed I currently have to redefine the ui router action types in my app.

skortchmark9 avatar Sep 29 '17 21:09 skortchmark9

Actually, a slightly more stable hack than defining them yourselves is to use the action creators:

const STATE_GO = stateGo().type

skortchmark9 avatar Oct 12 '17 07:10 skortchmark9

Incidentally, you might want to change your namespacing - it breaks https://github.com/wix/redux-saga-tester/blob/master/src/SagaTester.js#L45

skortchmark9 avatar Oct 12 '17 07:10 skortchmark9