Created
October 12, 2017 16:19
-
-
Save JamesTheHacker/52db6bb18ea7ca38f54afdc8907b07e9 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
// Subscribe to receive notifications | |
store.subscribe(action => { | |
// Check the type of action | |
if(action == ‘TWEETS_RECEIVED’) { | |
// Clear notification | |
document.getElementById(‘notification’).innerText = ‘’; | |
// Construct the HTML for the tweets list | |
const tweets = store.getState().tweets.map(tweet => { | |
return` | |
<li> | |
<p class=”username”>${tweet.username}</p> | |
<p class=”message”>${tweet.message}</p> | |
</li> | |
`; | |
}) | |
// Add tweets to UI | |
document.getElementById(‘tweets’).innerHTML = tweets; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment