Skip to content

Commit e6020b9

Browse files
authored
feat(ws-client): allow change reactive for state, filesMap and idMap (#5906)
1 parent 0dda80e commit e6020b9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/ws-client/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface VitestClientOptions {
1414
reconnectInterval?: number
1515
reconnectTries?: number
1616
connectTimeout?: number
17-
reactive?: <T>(v: T) => T
17+
reactive?: <T>(v: T, forKey: 'state' | 'idMap' | 'filesMap') => T
1818
ref?: <T>(v: T) => { value: T }
1919
WebSocketConstructor?: typeof WebSocket
2020
}
@@ -44,10 +44,10 @@ export function createClient(url: string, options: VitestClientOptions = {}) {
4444
state: new StateManager(),
4545
waitForConnection,
4646
reconnect,
47-
}) as VitestClient
47+
}, 'state') as VitestClient
4848

49-
ctx.state.filesMap = reactive(ctx.state.filesMap)
50-
ctx.state.idMap = reactive(ctx.state.idMap)
49+
ctx.state.filesMap = reactive(ctx.state.filesMap, 'filesMap')
50+
ctx.state.idMap = reactive(ctx.state.idMap, 'idMap')
5151

5252
let onMessage: Function
5353
const functions: WebSocketEvents = {

0 commit comments

Comments
 (0)