Created
August 1, 2015 11:48
-
-
Save hedgerh/78ea6ebdb71e2320e11c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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), | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use statics'; | |
export default { | |
FETCH_ME: 'FETCH_ME', | |
FETCH_LIKES: 'FETCH_LIKES', | |
FETCH_TRACKS: 'FETCH_TRACKS', | |
FETCH_USER: 'FETCH USER' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the file ActionTypes.js, what is the use of
'use statics';
?