voice v1.1
This commit is contained in:
30
src/renderer/realtime/voice/voiceStore.ts
Normal file
30
src/renderer/realtime/voice/voiceStore.ts
Normal file
@ -0,0 +1,30 @@
|
||||
type VoiceState = {
|
||||
connected: boolean;
|
||||
participants: string[];
|
||||
muted: boolean;
|
||||
};
|
||||
|
||||
const state: VoiceState = {
|
||||
connected: false,
|
||||
participants: [],
|
||||
muted: false,
|
||||
};
|
||||
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
export function getVoiceState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
export function setVoiceState(patch: Partial<VoiceState>) {
|
||||
Object.assign(state, patch);
|
||||
listeners.forEach((l) => l());
|
||||
}
|
||||
|
||||
export function subscribeVoice(cb: () => void): () => void {
|
||||
listeners.add(cb);
|
||||
|
||||
return () => {
|
||||
listeners.delete(cb);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user