Put connection setup state in redux
Summary: Puts the connection state into redux so we have more visibility on what's happening in bug reports and in general allowing us to display it on screen. Reviewed By: passy Differential Revision: D13060455 fbshipit-source-id: c79b4b7d6a1155d86128a5d8d1174ead9e4514ae
This commit is contained in:
committed by
Facebook Github Bot
parent
6362188563
commit
866cb72124
@@ -10,6 +10,7 @@ import Server from '../server.js';
|
||||
import type {Store} from '../reducers/index.js';
|
||||
import type Logger from '../fb-stubs/Logger.js';
|
||||
import type Client from '../Client.js';
|
||||
import type {UninitializedClient} from '../UninitializedClient';
|
||||
|
||||
export default (store: Store, logger: Logger) => {
|
||||
const server = new Server(logger, store);
|
||||
@@ -45,6 +46,33 @@ export default (store: Store, logger: Logger) => {
|
||||
});
|
||||
});
|
||||
|
||||
server.addListener('start-client-setup', (client: UninitializedClient) => {
|
||||
store.dispatch({
|
||||
type: 'START_CLIENT_SETUP',
|
||||
payload: client,
|
||||
});
|
||||
});
|
||||
|
||||
server.addListener(
|
||||
'finish-client-setup',
|
||||
(payload: {client: UninitializedClient, deviceId: string}) => {
|
||||
store.dispatch({
|
||||
type: 'FINISH_CLIENT_SETUP',
|
||||
payload: payload,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
server.addListener(
|
||||
'client-setup-error',
|
||||
(payload: {client: UninitializedClient, error: Error}) => {
|
||||
store.dispatch({
|
||||
type: 'CLIENT_SETUP_ERROR',
|
||||
payload: payload,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
window.addEventListener('beforeunload', () => {
|
||||
server.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user