1
1
import type { Fn } from '@vueuse/shared'
2
2
import type { MaybeRefOrGetter , Ref , ShallowRef } from 'vue'
3
3
import { isClient , toRef , tryOnScopeDispose } from '@vueuse/shared'
4
- import { ref as deepRef , shallowReadonly , shallowRef , watch } from 'vue'
4
+ import { ref as deepRef , shallowRef , watch } from 'vue'
5
5
import { useEventListener } from '../useEventListener'
6
6
7
7
export type EventSourceStatus = 'CONNECTING' | 'OPEN' | 'CLOSED'
@@ -55,23 +55,23 @@ export interface UseEventSourceReturn<Events extends string[], Data = any> {
55
55
* Reference to the latest data received via the EventSource,
56
56
* can be watched to respond to incoming messages
57
57
*/
58
- readonly data : Readonly < ShallowRef < Data > >
58
+ data : ShallowRef < Data >
59
59
60
60
/**
61
61
* The current state of the connection, can be only one of:
62
62
* 'CONNECTING', 'OPEN' 'CLOSED'
63
63
*/
64
- readonly status : Readonly < ShallowRef < EventSourceStatus > >
64
+ status : ShallowRef < EventSourceStatus >
65
65
66
66
/**
67
67
* The latest named event
68
68
*/
69
- readonly event : Readonly < ShallowRef < Events [ number ] | null > >
69
+ event : ShallowRef < Events [ number ] | null >
70
70
71
71
/**
72
72
* The current error
73
73
*/
74
- readonly error : Readonly < ShallowRef < Event | null > >
74
+ error : ShallowRef < Event | null >
75
75
76
76
/**
77
77
* Closes the EventSource connection gracefully.
@@ -92,7 +92,7 @@ export interface UseEventSourceReturn<Events extends string[], Data = any> {
92
92
* The last event ID string, for server-sent events.
93
93
* @see https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/lastEventId
94
94
*/
95
- readonly lastEventId : Readonly < ShallowRef < string | null > >
95
+ lastEventId : ShallowRef < string | null >
96
96
}
97
97
98
98
function resolveNestedOptions < T > ( options : T | true ) : T {
@@ -214,12 +214,12 @@ export function useEventSource<Events extends string[], Data = any>(
214
214
215
215
return {
216
216
eventSource,
217
- event : shallowReadonly ( event ) ,
218
- data : shallowReadonly ( data ) ,
219
- status : shallowReadonly ( status ) ,
220
- error : shallowReadonly ( error ) ,
217
+ event,
218
+ data,
219
+ status,
220
+ error,
221
221
open,
222
222
close,
223
- lastEventId : shallowReadonly ( lastEventId ) ,
223
+ lastEventId,
224
224
}
225
225
}
0 commit comments