Better client unmounting in simulator.

This commit is contained in:
empathicqubit 2018-05-27 17:53:01 -04:00
parent a28938aaa2
commit 034aac99d9
2 changed files with 7 additions and 3 deletions

View file

@ -61,6 +61,7 @@ function getProps (render) {
}
let client = {
_backend: backend,
sources: [],
realPosition: 0,
clientId: 0,
@ -76,9 +77,6 @@ function getProps (render) {
client.name = name;
render();
},
onComponentUnmount: () => {
backend.close();
}
};
StartAudioContext(backend._context, '.playit')
@ -123,6 +121,9 @@ function getProps (render) {
render();
},
onSubmitPassword: (password) => doHello(password),
onComponentUnmount: () => {
clients.forEach(x => x._backend.close());
},
onChangePassword: (password) => {
simulator.password = password;
render();

View file

@ -9,6 +9,9 @@ class Simulator extends React.Component {
constructor(props) {
super(props);
}
componentWillUnmount() {
this.props.onComponentUnmount && this.props.onComponentUnmount();
}
render() {
return (
<div>