From 0aba68062b91f55dd5f41a48bc82b70555f34183 Mon Sep 17 00:00:00 2001 From: userquin Date: Mon, 17 Jun 2024 12:36:54 +0200 Subject: [PATCH] feat(ws-client): allow change reactive for state, filesMap and idMap --- packages/ws-client/src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ws-client/src/index.ts b/packages/ws-client/src/index.ts index 115f6a27f2c6..99d7ae3576f0 100644 --- a/packages/ws-client/src/index.ts +++ b/packages/ws-client/src/index.ts @@ -14,7 +14,7 @@ export interface VitestClientOptions { reconnectInterval?: number reconnectTries?: number connectTimeout?: number - reactive?: (v: T) => T + reactive?: (v: T, forKey: 'state' | 'idMap' | 'filesMap') => T ref?: (v: T) => { value: T } WebSocketConstructor?: typeof WebSocket } @@ -44,10 +44,10 @@ export function createClient(url: string, options: VitestClientOptions = {}) { state: new StateManager(), waitForConnection, reconnect, - }) as VitestClient + }, 'state') as VitestClient - ctx.state.filesMap = reactive(ctx.state.filesMap) - ctx.state.idMap = reactive(ctx.state.idMap) + ctx.state.filesMap = reactive(ctx.state.filesMap, 'filesMap') + ctx.state.idMap = reactive(ctx.state.idMap, 'idMap') let onMessage: Function const functions: WebSocketEvents = {