Skip to content

Commit 5fbf138

Browse files
committed
feat: remove -Instance suffix and rename to useXXXReturn
1 parent 37894f3 commit 5fbf138

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/react/src/hooks/useAgent.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type AgentActions = {
142142
};
143143

144144
type AgentStateCases = AgentStateConnecting | AgentStateAvailable | AgentStateAvailableListening | AgentStateUnAvailable | AgentStateFailed;
145-
export type AgentInstance = AgentStateCases & AgentActions;
145+
export type UseAgentReturn = AgentStateCases & AgentActions;
146146

147147
const generateDerivedStateValues = <State extends AgentState>(state: State) => ({
148148
isAvailable: (
@@ -240,7 +240,7 @@ type ConversationStub = Pick<ConversationInstance, 'connectionState' | 'subtle'>
240240
/**
241241
* useAgent encapculates all agent state, normalizing some quirks around how LiveKit Agents work.
242242
*/
243-
export function useAgent(conversation: ConversationStub, _name?: string): AgentInstance {
243+
export function useAgent(conversation: ConversationStub, _name?: string): UseAgentReturn {
244244
const { room } = conversation.subtle;
245245

246246
const emitter = useMemo(() => new EventEmitter() as TypedEventEmitter<AgentCallbacks>, []);
@@ -268,7 +268,7 @@ export function useAgent(conversation: ConversationStub, _name?: string): AgentI
268268
return;
269269
}
270270

271-
const handleAttributesChanged = (attributes: AgentInstance["attributes"]) => {
271+
const handleAttributesChanged = (attributes: UseAgentReturn["attributes"]) => {
272272
setAgentParticipantAttributes(attributes);
273273
emitter.emit(AgentEvent.AttributesChanged, attributes);
274274
};

packages/react/src/hooks/useConversationWith.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ type ConversationActions = {
116116
end: () => Promise<void>;
117117
};
118118

119-
export type ConversationInstance = (ConversationStateConnecting | ConversationStateConnected | ConversationStateDisconnected) & ConversationActions;
119+
export type UseConversationReturn = (ConversationStateConnecting | ConversationStateConnected | ConversationStateDisconnected) & ConversationActions;
120120

121121
/**
122122
* AgentSession represents a connection to a LiveKit Agent, providing abstractions to make 1:1
123123
* agent/participant rooms easier to work with.
124124
*/
125-
export function useConversationWith(agentToDispatch: string | RoomAgentDispatch | null, options: ConversationOptions): ConversationInstance {
125+
export function useConversationWith(agentToDispatch: string | RoomAgentDispatch | null, options: ConversationOptions): UseConversationReturn {
126126
const roomFromContext = useMaybeRoomContext();
127127
const room = useMemo(() => roomFromContext ?? options.room ?? new Room(), [roomFromContext, options.room]);
128128

@@ -145,7 +145,7 @@ export function useConversationWith(agentToDispatch: string | RoomAgentDispatch
145145
};
146146
}, [options.tokenSource]);
147147

148-
const generateDerivedConnectionStateValues = useCallback(<State extends ConversationInstance["connectionState"]>(connectionState: State) => ({
148+
const generateDerivedConnectionStateValues = useCallback(<State extends UseConversationReturn["connectionState"]>(connectionState: State) => ({
149149
isConnected: (
150150
connectionState === ConnectionState.Connected ||
151151
connectionState === ConnectionState.Reconnecting ||
@@ -275,13 +275,13 @@ export function useConversationWith(agentToDispatch: string | RoomAgentDispatch
275275
emitter.emit(ConversationEvent.ConnectionStateChanged, conversationState.connectionState);
276276
}, [emitter, conversationState.connectionState]);
277277

278-
const waitUntilConnectionState = useCallback(async (state: ConversationInstance["connectionState"], signal?: AbortSignal) => {
278+
const waitUntilConnectionState = useCallback(async (state: UseConversationReturn["connectionState"], signal?: AbortSignal) => {
279279
if (conversationState.connectionState === state) {
280280
return;
281281
}
282282

283283
return new Promise<void>((resolve, reject) => {
284-
const onceEventOccurred = (newState: ConversationInstance["connectionState"]) => {
284+
const onceEventOccurred = (newState: UseConversationReturn["connectionState"]) => {
285285
if (newState !== state) {
286286
return;
287287
}
@@ -393,6 +393,6 @@ export function useConversationWith(agentToDispatch: string | RoomAgentDispatch
393393
]);
394394
}
395395

396-
export function useConversation(options: ConversationOptions): ConversationInstance {
396+
export function useConversation(options: ConversationOptions): UseConversationReturn {
397397
return useConversationWith(null, options);
398398
}

0 commit comments

Comments
 (0)