Join Alex Banks for an in-depth discussion in this video Saving audience state, part of Building a Polling App with Socket IO and React.js.
- As new members join our presentation,…we're going to need to save them to an array.…We are going to use an audience variable…to manage all of our audience members.…So that is going to be one of our state variables…that will start here on the server.…I am looking at the app-server.js file,…and I'm coming into line 5 here.…I'm going to drop my cursor right at the end of line 5…and hit enter, and I will create a variable for audience.…So this audience variable is going to be an array,…and as members join, we want to add them to this array.…So when a member joins, it is being handled down here,…inside this event handler for the join event.…
So on line 22, this callback function…handles new audience member joins.…Now, we're emitting a join event to the socket…that recently joined, but we also need…to save the audience member to that array.…So I could just use audience.push…to push the newMember into that array.…So now when members join, we're going to…go ahead and add them to the array.…But now what we need to do is, we need to update…
- Setting up the environment
- Connecting sockets
- Handling disconnects
- Setting up the React.js router
- Passing state to child components as properties
- Joining the presentation
- Starting and running the presentation
- Asking and answering questions
- Graphing results
- Upgrading to ES6
Skill Level Intermediate
Building a Responsive Single-Page Design with Sasswith Ray Villalobos4h 55m Intermediate
1. Setting Up the Environment
Setting up npm scripts4m 22s
2. Connecting Sockets
3. App State and Routes
4. Joining the Presentation
5. Starting the Presentation
6. Questions and Answers
7. Graphing Results on a Scoreboard
8. Upgrading to ES6 Syntax
Next steps1m 1s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.