neilff / redux-ui-router

ngRedux bindings for Angular UI Router
MIT License
143 stars 48 forks source link

Add ability to import the constants of the action-types #90

Open ondrasak opened 7 years ago

ondrasak commented 7 years ago

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

hally9k commented 7 years ago

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

ondrasak commented 7 years ago

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
hally9k commented 7 years ago

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 👍

skortchmark9 commented 6 years ago

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

skortchmark9 commented 6 years ago

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

const STATE_GO = stateGo().type
skortchmark9 commented 6 years ago

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