Skip to content

Commit

Permalink
Merge branch 'main' into alkwa/update-calling-1.33.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alkwa-msft authored Mar 10, 2025
2 parents 89141d6 + ee694fe commit b069dcc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "Bugs",
"comment": "update the max number of listeners that the CallWIthChat adapter has",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "Bugs",
"comment": "update the max number of listeners that the CallWIthChat adapter has",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,21 @@ import { busyWait } from '../../common/utils';

type CallWithChatAdapterStateChangedHandler = (newState: CallWithChatAdapterState) => void;

/**
* For each time that we use the hook {@link useSelector} in the {@link CallWithChatComposite} we add another listener
* to the `stateChanged` event on the this adapter. This number is set in relation to the number of
* times that we are using the hook useSelector in the CallComposite.
*
* We will need to update this as the threshold is reached with more usages of useSelector.
*/
const MAX_EVENT_LISTENERS = 125;

/** Context of Call with Chat, which is a centralized context for all state updates */
class CallWithChatContext {
private emitter = new EventEmitter();
private state: CallWithChatAdapterState;

constructor(clientState: CallWithChatAdapterState, maxListeners = 50) {
constructor(clientState: CallWithChatAdapterState, maxListeners = MAX_EVENT_LISTENERS) {
this.state = clientState;
this.emitter.setMaxListeners(maxListeners);
}
Expand Down

0 comments on commit b069dcc

Please sign in to comment.