danscan / rn-redux-mixpanel

Configurable redux middleware that sends your actions & user profile data to Mixpanel. Works with React Native!
67 stars 14 forks source link

Use named functions instead of anonymous functions #12

Closed cgarvis closed 8 years ago

cgarvis commented 8 years ago

ES6 default exports are a bit weird. You can't initialize variables in a onliner like the current implementation which uses anonymous functions. But if you remove the variable name you lose the awesome stacktrace. Initializing the function as a constant just adds too much boilerplate.

Named functions seem to be the best compromise outside of using a babel transformation like babel-plugin-transform-export-default-name which is overkill for a library.

danscan commented 8 years ago

That needed a quick fix for an unexpected token. I fixed and published it. I threw this together a while ago, but it should really have unit tests. I'll set some time to add some this weekend.

danscan commented 8 years ago

I've written a similar lib: https://github.com/danscan/react-native-redux-segment (docs coming shortly) that works with segment.com, which I'm using in a different project.

I'll add tests to this project along with that one this weekend. Then I can swap out superagent for axios in this project, since it's a lot nicer.

cgarvis commented 8 years ago

Awesome. Thanks!

Think hard about using fetch. I don't use superagent or axios in any of my projects. You only have one AJAX call. It even make sense to use XMLHttpRequest so as not add dependencies to people's projects that don't need them. If you want, I'll setup a PR for XMLHttpRequest.