mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-16 07:48:49 +00:00
feat: added laravel reverb and websocket, also emote throwing added
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { onScopeDispose, watch } from 'vue';
|
||||
|
||||
import { getEcho } from '@/lib/echo';
|
||||
import type { PaperBallThrownPayload } from '@/types/emote';
|
||||
|
||||
const PAPER_BALL_EVENT = '.room.emote.thrown';
|
||||
|
||||
export function useRoomEmotes(
|
||||
roomId: () => string,
|
||||
onPaperBallThrown: (payload: PaperBallThrownPayload) => void,
|
||||
): void {
|
||||
const stopWatchingRoom = watch(
|
||||
roomId,
|
||||
(nextRoomId, _previousRoomId, onCleanup) => {
|
||||
const channel = getEcho().channel(`rooms.${nextRoomId}`);
|
||||
|
||||
channel.listen(PAPER_BALL_EVENT, onPaperBallThrown);
|
||||
|
||||
onCleanup(() => {
|
||||
channel.stopListening(PAPER_BALL_EVENT, onPaperBallThrown);
|
||||
});
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
onScopeDispose(stopWatchingRoom);
|
||||
}
|
||||
Reference in New Issue
Block a user