Event Listener

The Javascript SDK provides interfaces to listen to various events on the client app. Through these interfaces, TapTalk.io notifies the client app of events that happen on your app.

TapTalk.io provides event listeners to notify events to the client app. You will need to register the listener objects to receive event callbacks from TapTalk.io.

TapListener

General events such as notifications will be notified through TapListener. A TapListener instance is required when initializing TapTalk.

taptalk.addTapListener({
      onTapTalkRefreshTokenExpired: () => {
        setIsModalRefreshReconnectShow(true);
      }
})

TapListener listens to changes in the following methods:

TapCoreMessageListener

TapCoreMessageListener listens to message-related events, such as receiving new or updated message. TapCoreMessageListener can be registered through the TapCoreMessageManager class.

tapCoreChatRoomManager.addMessageListener({
        onReceiveNewMessage: (messageModel) => {
          // do action here
        },

        onReceiveUpdateMessage: (messageModel) => {
          // do action here
        }
})

TapCoreRoomListListener

Changes to a chat room's state, such as pin and mute events are notified through TapCoreRoomListListener. An instance of TapCoreRoomListListener can be registered from the TapCoreRoomListManager class.

tapCoreRoomListManager.addRoomListListener({
    onChatRoomDeleted: (roomID) => {
        // do action here
    }
});

TapCoreChatRoomListener

Room status events such as typing events and online status are notified through TapCoreChatRoomListener. An instance of TapCoreChatRoomListener can be registered from the TapCoreChatRoomManager class.

tapCoreChatRoomManager.addRoomStatusListener( {
        onReceiveStartTyping: (roomID, userModel) => {
          // do action here
        },

        onReceiveStopTyping: (roomID, userModel) => {
          // do action here
        },

        onReceiveOnlineStatus: (userModel, isOnline, lastActive) => {
          // do action here
        }
 })

TapCoreContactListener

Contact related events such as block/unblock are notified through TapCoreContactListener. An instance of TapCoreContactListener can be registered from the TapCoreContactManager class.

tapCoreContactManager.addContactListener({
    onContactBlocked: (user) => {
    
    },
    onContactUnblocked: (user) => {
    
    }
});

Last updated