Skip to content

Data Structure to factory pattern and entity pattern #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove semicolon to padronize the syntax
  • Loading branch information
FelipeBarrosCruz committed May 5, 2017
commit b87cc63b13774664ab6f97015963232c58548851
14 changes: 7 additions & 7 deletions 5-redux-react/src/js/actions/tweetsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ export function fetchTweets() {
if (!Array.isArray(data)) return [];
return data.filter(value => !!value).reduce((merge, value) => {
if (value.myArray && Array.isArray(value.myArray)) {
merge = merge.concat(value.myArray);
merge = merge.concat(value.myArray)
}
return merge;
}, []);
return merge
}, [])
}

function buildTweetsUrl(user) {
return `http://rest.learncode.academy/api/${user}/tweets`;
return `http://rest.learncode.academy/api/${user}/tweets`
}

function requestTweets(url, done) {
axios.get(url).then(response => done(null, response)).catch(err => done(err, null));
axios.get(url).then(response => done(null, response)).catch(err => done(err, null))
}

return function(dispatch) {
Expand All @@ -30,9 +30,9 @@ export function fetchTweets() {
*/
requestTweets(buildTweetsUrl(TWEETS_USER), (err, response) => {
if (err || !response && !response.data || Array.isArray(response.data) && !response.data.length) {
return dispatch({type: "FETCH_TWEETS_REJECTED", payload: err || new Error('Tweets are empty')});
return dispatch({type: "FETCH_TWEETS_REJECTED", payload: err || new Error('Tweets are empty')})
}
return dispatch({type: "FETCH_TWEETS_FULFILLED", payload: filterPayloadDataToReturn(response.data)});
return dispatch({type: "FETCH_TWEETS_FULFILLED", payload: filterPayloadDataToReturn(response.data)})
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion 5-redux-react/src/js/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class Layout extends React.Component {
}

render() {
const { user, tweets } = this.props;
const { user, tweets } = this.props

if (!tweets.length) {
return <button onClick={this.fetchTweets.bind(this)}>load tweets</button>
Expand Down
4 changes: 2 additions & 2 deletions 5-redux-react/src/js/entities/tweetEntity.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default class Tweet {
constructor (value) {
if (value.id && value.tweet) {
this.id = value.id;
this.text = value.tweet;
this.id = value.id
this.text = value.tweet
}
}
}