redux-devtools/packages/redux-devtools-app/src/reducers/connection.ts
renovate[bot] 922985f9ea
chore(deps): update dependency prettier to v3 (#1434)
* chore(deps): update dependency prettier to v3

* Format

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Nathan Bierema <nbierema@gmail.com>
2023-07-12 18:03:20 +00:00

27 lines
684 B
TypeScript

import { RECONNECT } from '../constants/socketActionTypes';
import { ConnectionType, StoreAction } from '../actions';
export interface ConnectionStateOptions {
readonly hostname: string;
readonly port: number;
readonly secure: boolean;
}
export interface ConnectionState {
readonly options: ConnectionStateOptions;
readonly type: ConnectionType;
}
export function connection(
state: ConnectionState = {
options: { hostname: 'localhost', port: 8000, secure: false },
type: 'disabled',
},
action: StoreAction,
) {
if (action.type === RECONNECT) {
const { type, ...options } = action.options;
return { ...state, type, options };
}
return state;
}