Skip to content

Instantly share code, notes, and snippets.

@pragmaticlogic
Last active August 29, 2015 14:21
Show Gist options
  • Save pragmaticlogic/8e40931e535960986115 to your computer and use it in GitHub Desktop.
Save pragmaticlogic/8e40931e535960986115 to your computer and use it in GitHub Desktop.
var Dashboard = React.createClass({
getInitialState() {
return {isLoading: true}
},
componentDidMount() {
var _My = new My()
var L = _My.MakeLenses(GHConst.githubApiFields)
var getGithub = url => new Future(function(reject, response) {
$.getJSON(url)
.done(function(data) {
response(data)
})
.fail(function(error) {
reject(error)
})
})
var githubUrl = R.concat(GHConst.baseUrl, this.props.data)
var context = this
var displayError = error => { context.setState({error, isLoading: false, id: this.props.data }) }
var displayData = data => { context.setState({
error: null,
isLoading: false,
avatar: L.avatar_url.get(data),
id: L.id.get(data),
name: L.name.get(data),
login: L.login.get(data),
company: L.company.get(data),
location: L.location.get(data),
followers: L.followers.get(data),
following: L.following.get(data),
email: L.email.get(data),
bio: L.bio.get(data),
public_repos: L.public_repos.get(data)
})}
getGithub(githubUrl).fork(displayError, displayData)
},
render() {
return ((context, props, state) => {
var _My = new My()
var L = _My.MakeLenses(['isLoading'])
var show = R.ifElse(L.isLoading, s => <Spinner />, s => <Github data={{githubData: s}} />)
return show(state)
})(this, this.props, this.state)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment