Skip to content

Instantly share code, notes, and snippets.

@hedgerh
Created August 1, 2015 11:48
Show Gist options
  • Save hedgerh/78ea6ebdb71e2320e11c to your computer and use it in GitHub Desktop.
Save hedgerh/78ea6ebdb71e2320e11c to your computer and use it in GitHub Desktop.
'use strict';
import request from 'superagent';
import { createAction } from 'redux-actions';
import ActionTypes from '../constants/ActionTypes';
import { SOUNDCLOUD_URL } from '../constants/static';
const fetchMe = (opts) => {
request.get(`${SOUNDCLOUD_URL}/me`)
.query(opts)
.end((err, res) => { me: res.body } };
} ))
}
export default {
fetchMe: createAction(ActionTypes.FETCH_ME, fetchMe),
};
'use statics';
export default {
FETCH_ME: 'FETCH_ME',
FETCH_LIKES: 'FETCH_LIKES',
FETCH_TRACKS: 'FETCH_TRACKS',
FETCH_USER: 'FETCH USER'
};
'use strict';
import React, { Component, PropTypes } from 'react';
import { connect } from 'redux/react';
import SoundcloudActions from '../../actions/soundcloud';
@connect(state => (state))
class AudioPlayerContainer extends Component {
constructor(props, context) {
super(props, context);
};
componentWillMount() {
const { dispatch } = this.props;
dispatch(SoundcloudActions.fetchMe({
client_id: '12345',
oauth_token: '54321'
}));
};
render() {
return (
<div/>
);
};
}
export default AudioPlayerContainer;
'use strict';
import { handleAction } from 'redux-actions';
import ActionTypes from '../constants/ActionTypes';
const fetchMe = handleAction(ActionTypes.FETCH_ME, {
next(state = {}, action) {
console.log('next');
},
throw(state, action) {
console.log('throw');
}
});
export default fetchMe;
'use strict';
import React, { Component, PropTypes } from 'react';
import { Provider } from 'redux/react';
import { createDispatcher, createRedux, composeStores } from 'redux';
import { loggerMiddleware, thunkMiddleware } from '../../middleware';
import reducers from '../../reducers/soundcloud';
import AudioPlayerContainer from '../AudioPlayer';
const dispatcher = createDispatcher(
composeStores(reducers),
getState => [ thunkMiddleware(getState), loggerMiddleware ]
);
const redux = createRedux(dispatcher);
class Root extends Component {
render() {
return (
<Provider redux={redux}>
{ () => <AudioPlayerContainer/> }
</Provider>
);
};
}
export default Root;
React.render(<Root/>, document.getElementById('ui-App'));
@zhirzh
Copy link

zhirzh commented Apr 15, 2016

In the file ActionTypes.js, what is the use of 'use statics';?

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