Created
May 14, 2021 19:00
-
-
Save amitrahav/400885d46f776546c46b8b9e05630d45 to your computer and use it in GitHub Desktop.
SocketVsSSE
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
import React from 'react' | |
import { connect } from 'react-redux'; | |
import MessagesActions from './store/messages/MessagesActions'; | |
class SSEComponent extends React.Component{ | |
componentDidMount(){ | |
// Open SSE connection with server - listen messages for the first index video | |
this.props.openVideoConnection(1) | |
} | |
render(){ | |
return ( | |
<ul> | |
{this.props.allVideos.map(video => | |
<li> video progress: {video?.progress}</li> | |
)} | |
</ul> | |
) | |
} | |
} | |
const mapStateToProps = (state) => ({ | |
allVideos: state.allVideos | |
}); | |
const mapDispatchToProps = { | |
openVideoConnection: MessagesActions.videoMessages | |
}; | |
export default connect( | |
mapStateToProps, | |
mapDispatchToProps | |
)(SSEComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment