This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
60 lines (52 loc) · 1.8 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { TranscriptState } from '../../../common/types/events.types';
import { RealtimeStateTypes } from '../../../common/types/realtime.types';
import { DrawingData } from '../../video-conference-manager/types';
import { Singleton } from '../common/types';
import { CreateSingleton } from '../common/utils';
import subject from '../subject';
const instance: Singleton<VideoStore> = CreateSingleton<VideoStore>();
export class VideoStore {
public meetingState = subject<RealtimeStateTypes>(RealtimeStateTypes.DISCONNECTED);
public gather = subject<boolean>(false);
public hostId = subject<string>('');
public isGridModeEnabled = subject<boolean>(false);
public followParticipantId = subject<string>('');
public drawing = subject<DrawingData>(null);
public transcript = subject<TranscriptState>(null);
constructor() {
if (instance.value) {
throw new Error('VideoStore is a singleton. There can only be one instance of it.');
}
instance.value = this;
}
public destroy() {
this.meetingState.destroy();
this.gather.destroy();
this.hostId.destroy();
this.isGridModeEnabled.destroy();
this.followParticipantId.destroy();
this.drawing.destroy();
this.transcript.destroy();
}
}
const store = new VideoStore();
const destroy = store.destroy.bind(store);
const meetingState = store.meetingState.expose();
const gather = store.gather.expose();
const hostId = store.hostId.expose();
const isGridModeEnabled = store.isGridModeEnabled.expose();
const followParticipantId = store.followParticipantId.expose();
const drawing = store.drawing.expose();
const transcript = store.transcript.expose();
export function useVideoStore() {
return {
meetingState,
gather,
destroy,
hostId,
isGridModeEnabled,
followParticipantId,
drawing,
transcript,
};
}