Skip to content

Instantly share code, notes, and snippets.

@amitrahav
Created May 14, 2021 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitrahav/400885d46f776546c46b8b9e05630d45 to your computer and use it in GitHub Desktop.
Save amitrahav/400885d46f776546c46b8b9e05630d45 to your computer and use it in GitHub Desktop.
SocketVsSSE
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