mirror of https://github.com/waku-org/js-waku.git
Display messages emitted by waku mock
This commit is contained in:
parent
ca7445d65c
commit
35db88a63e
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue