diff --git a/front/src/Api/iframe/chat.ts b/front/src/Api/iframe/chat.ts index 0d467c2c..5f73b744 100644 --- a/front/src/Api/iframe/chat.ts +++ b/front/src/Api/iframe/chat.ts @@ -2,13 +2,15 @@ import type { ChatEvent } from '../Events/ChatEvent' import { isUserInputChatEvent, UserInputChatEvent } from '../Events/UserInputChatEvent' import { IframeApiContribution, sendToWorkadventure } from './IframeApiContribution' import { apiCallback } from "./registeredCallbacks"; +import {Subject} from "rxjs"; + +const chatStream = new Subject(); class WorkadventureChatCommands extends IframeApiContribution { - chatMessageCallback?: (event: string) => void callbacks = [apiCallback({ callback: (event: UserInputChatEvent) => { - this.chatMessageCallback?.(event.message) + chatStream.next(event.message); }, type: "userInputChat", typeChecker: isUserInputChatEvent @@ -29,7 +31,7 @@ class WorkadventureChatCommands extends IframeApiContribution void) { - this.chatMessageCallback = callback + chatStream.subscribe(callback); } }