Created
          December 25, 2016 04:24 
        
      - 
      
- 
        Save vincent144/026ec50b299526b40dd20a0d84d705b8 to your computer and use it in GitHub Desktop. 
    React Native Socket.io Existing Messages
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | socket.on('connection', () => { | |
| var messages = db.collection('messages').find({ | |
| chatId: chatId // We want all the messages for that room. | |
| }).sort({ | |
| createdAt: -1 // It's best not to assume that it is in order. | |
| }); | |
| socket.emit('message', messages); | |
| }); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment