FlipperClientConnection no longer redefines the RSocket Socket interface

Summary:
FlipperClientConnection used to define an interface which closely matched the Socket interface defined in RSocket.

Presumably it tried to 'decouple' RSocket from consumers of the client socket connection. It also limited the amount of actions that could be triggered on said socket connection.

This diff does two things:
- Renames FlipperClientConnection to ClientConnection.
- Changes the interface so that it no longer matches the RSocket Socket interface. The new interface doesn't use RSocket reactive types either.

As a result, current implementations of the interface will act as a proxy to the RSocket Socket type. The change allows the usage of other implementations such as WebSocket.

Reviewed By: fabiomassimo

Differential Revision: D29934090

fbshipit-source-id: 02742e50cd6e801310698969c81b3bf1ef0fa2a2
This commit is contained in:
Lorenzo Blasa
2021-07-27 08:28:37 -07:00
committed by Facebook GitHub Bot
parent 8bb47a38a1
commit c1496f621e
6 changed files with 307 additions and 253 deletions

View File

@@ -11,7 +11,11 @@ import {createStore} from 'redux';
import BaseDevice from '../devices/BaseDevice';
import {createRootReducer} from '../reducers';
import {Store} from '../reducers/index';
import Client, {ClientQuery, FlipperClientConnection} from '../Client';
import Client, {ClientQuery} from '../Client';
import {
ClientConnection,
ConnectionStatusChange,
} from '../comms/ClientConnection';
import {buildClientId} from '../utils/clientUtils';
import {Logger} from '../fb-interfaces/Logger';
import {PluginDefinition} from '../plugin';
@@ -235,33 +239,17 @@ export default class MockFlipper {
return client;
}
}
function createStubConnection():
| FlipperClientConnection<any, any>
| null
| undefined {
function createStubConnection(): ClientConnection | null | undefined {
return {
subscribeToEvents(_: ConnectionStatusChange) {},
close() {
throw new Error('Should not be called in test');
},
fireAndForget() {
send(_: any) {
throw new Error('Should not be called in test');
},
requestResponse() {
sendExpectResponse(_: any): Promise<ResponseType> {
throw new Error('Should not be called in test');
},
connectionStatus() {
return {
subscribe() {},
lift() {
throw new Error('Should not be called in test');
},
map() {
throw new Error('Should not be called in test');
},
take() {
throw new Error('Should not be called in test');
},
};
},
};
}