mirror of
https://github.com/waku-org/js-waku.git
synced 2025-02-20 16:18:21 +00:00
Display messages emitted by waku mock
This commit is contained in:
parent
ca7445d65c
commit
35db88a63e
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import Room from './Room';
|
import Room from './Room';
|
||||||
|
import WakuMock from './WakuMock';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
}
|
}
|
||||||
@ -14,8 +15,16 @@ class App extends React.Component<Props, State> {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
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() {
|
render() {
|
||||||
|
@ -35,7 +35,7 @@ export default class WakuMock extends EventEmitter<Message> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async create(): Promise<WakuMock> {
|
public static async create(): Promise<WakuMock> {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
|
|
||||||
const wakuMock = new WakuMock();
|
const wakuMock = new WakuMock();
|
||||||
wakuMock.startInterval();
|
wakuMock.startInterval();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user