Skip to main content

App State Library

Provides accessors for various app states used in App Builder. Some accessors accept a selector method that allows for selective subscribing of data.


useRecording(selector?: Selector): RecordingContextInterface

The Recording app state governs the App Builder cloud recording functionality.


RecordingContextInterface

KeyTypeDescription
isRecordingActivebooleanIndicates if cloud recording is active in the application
startRecording() => voidStarts cloud recording
stopRecording() => voidStops cloud recording

Usage example of the app state:


useSidePanel(selector?: Selector): SidePanelContextInterface

The SidePanel app state governs the sidePanel ui.


SidePanelContextInterface

KeyTypeDescription
sidePanelSidePanelTypeActive sidepanel name
setSidePanel( sidepanel: SidePanelType ) => voidMethod to set active sidepanel name

SidePanelType

NameValue
None0
Participants1
Chat2
Settings3

Usage example of the app state:


useChatUIControl(selector?: Selector): ChatUIControlInterface

The ChatUIControl app state governs the chat ui.


ChatUIControlInterface

KeyTypeDescription
groupActivebooleanDetermines if group tab is active in chat sidepanel
setGroupActive(status: boolean) => voidMethod to set group tab active status
privateActivebooleanDetermines if private tab is active in chat sidepanel
setPrivateActive(status: boolean) => voidMethod to set private tab active status
selectedChatUserIduidtypeUid of the user selected in private chat tab
setSelectedChatUserId(uid: uidtype ) => voidMethod to set selected user
messagestringContent of message to be sent
setMessage(message: string) => voidMethod to set content of message to be sent

Usage example of the app state:


useMessages(): MessageInterface

The Messages app state governs the chat messages.


MessageInterface

KeyTypeDescription
groupMessagesMessageStoreInterface[]Array of all the group messages
privateMessages{ [key: string]: MessageStoreInterface[] }Object containing all private messages
sendMessage( msg: string, toUid?: number ) => voidMethod to send a message. Sends group message if toUid is not passed
editMessage( msgId: string, msg: string, toUid?: number ) => voidMethod to edit a message
deleteMessage( msgId: string, toUid?: number ) => voidMethod to delete a message
groupUnreadCountnumberNumber of unread group messages
setGroupUnreadCount(count: number) => voidmethod to set number of unread group messages
individualUnreadCount{ [key: string]: number }object containing number of unread private messages corresponding to each uid
setIndividualUnreadCount(count: { [key: string]: number } ) => voidmethod to set nubmer of unread private messages

MessageStoreInterface

keytypedescription
createdTimestampnumbermessage creation timestamp
updatedTimestamp?numberlast message update timestamp
msgstringmessage content
msgIdstringmessage id
isDeletedbooleanindicates if message is deleted
uidUidTypeuid of the message sender

usage example of the app state:


useRender(selector?: Selector): RenderStateInterface

The Render app state governs the information necessary to render each user content view displayed in the videocall screen.

it is composed of:

RenderStateInterface

keytypedescription
renderListRenderObjectsObject containing information necessary to render the content view corresponding to each uid in the Render app state
activeUidsarray<Uidtype>Array of all uids in the Render app state

Each renderobject in the renderlist is passed as a prop to corresponding type of content component. All the resulting components are then passed to the layouts as an array to be rendered as desired.

For eg. The Render app state contains a renderobject of type:'rtc' for each user in the meeting by default stored in renderList. It is used to display user video feeds coming from AgoraRTC hence they contain all the necessary information like: uid to identify and subscribe to the video and audio, audio and video mute states to correctly display fallbacks and icons, etc. each Renderobject is passed as a prop to MaxVideoView unless overridden by CustomContent API. After which the resulting array of components is passed to layout to be rendered.

tip

You can add custom render objects to the render app state using the 'AddCustomContent' action in dispatch

Usage example of the app state:


useLocalUserInfo(): LocalUserInfo

The LocalUserInfo app state contains the local user information like uid, audio and video mute states etc.

Usage example of the app state:


useLayout(selector?: Selector): LayoutContextInterface

The Layout app state governs the video call screen content display layout.


LayoutContextInterface

KeyTypeDescription
currentLayoutstringName of the current layout. Can be grid, pinned or any other key defined in the custom layout API
setLayout( layoutName: string ) => voidSets the current layout with given layout name

Usage example of the app state:


useMeetingInfo(selector?: Selector): MeetingInfoContextInterface

The MeetingInfo app state contains information about the active meeting.


MeetingInfoContextInterface

KeyTypeDescription
isJoinDataFetchedbooleanIndicates meeting info has been fetched from the backend
data?MeetingInfoDataMeeting info data

MeetingInfoData

KeyTypeDescription
isHostbooleanIndicates if the user joined using the Host URL or using the Attendee URL
meetingTitlestringMeeting title
roomId{
attendee: string,
host?: string,
}
Host and attendee roomIds
pstn?{
number: string,
pin: string
}
PSTN info
isSeparateHostLinkbooleanIndicates if seperate host and attendee links generated
channel?stringChannel name of current meeting
uid?UidTypeUid of the local user
token?stringRTC authentication token required to join the channel
rtmToken?stringRTM authentication token required to join the channel
encryptionSecret?stringPacket encryption secret
screenShareUid?stringUid of local user's screenshare
screenShareToken?stringAuthentication token for local user's screenshare

Usage example of the app state:


useUserName(): [userName, setUserName]

The UserName app state governs the local user's display name.

Usage example of the app state:


Returns:

userName: string


setUserName: (name: string) => void;


useRtc(selector?: Selector): RtcInterface

The RTC app state exposes the internal RtcEngine object as well as dispatch interface to perform various actions.


RtcInterface

KeyTypeDescription
RtcEngineRtcEngineThe RtcEngine object from the AgoraRTC SDK
dispatchDispatchTypeMethod to perform various app builder actions. You can see list of available actions here.
setDualStreamMode( mode: DualStreamMode ): voidMethod to modify dual stream mode
danger

Avoid using RtcEngine directly to perform actions such as muting audio, joining a channel etc. Instead rely on Actions Library or Dispatch provided by the customization-api as they handle modifying the internal app states along with performing the required action.


Usage example of the app state: