Display messages emitted by waku mock

This commit is contained in:
Franck Royer 2021-04-19 10:36:37 +10:00 committed by Franck Royer
parent ca7445d65c
commit 35db88a63e
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 11 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import React from 'react';
import './App.css';
import Room from './Room';
import WakuMock from './WakuMock';
interface Props {
}
@ -14,8 +15,16 @@ class App extends React.Component<Props, State> {
super(props);
this.state = {
messages: ['Here is a line', 'Here is another line']
messages: []
};
WakuMock.create().then((wakuMock) => {
wakuMock.on('message',(message)=>{
const messages = this.state.messages.slice();
messages.push(message.message);
this.setState({messages});
})
});
}
render() {

View File

@ -35,7 +35,7 @@ export default class WakuMock extends EventEmitter<Message> {
}
public static async create(): Promise<WakuMock> {
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, 500));
const wakuMock = new WakuMock();
wakuMock.startInterval();