Handles the voting process for a poll.
The options for handling the vote.
The ID of the poll.
The index of the selected option.
The socket instance for communication.
Optional function to show alerts.
The member who is voting.
The name of the room where the poll is conducted.
Function to update the visibility of the poll modal.
A promise that resolves when the vote is handled.
Will log an error message if there is an issue submitting the vote.
const handleVotePollService = new HandleVotePoll();await handleVotePollService.handleVotePoll({ pollId: '12345', optionIndex: 1, socket: socketInstance, member: 'user1', roomName: 'room1', showAlert: ({ message, type }) => { console.log(`Alert: ${message} - Type: ${type}`); }, updateIsPollModalVisible: (isVisible) => { console.log('Poll modal visibility:', isVisible); },}); Copy
const handleVotePollService = new HandleVotePoll();await handleVotePollService.handleVotePoll({ pollId: '12345', optionIndex: 1, socket: socketInstance, member: 'user1', roomName: 'room1', showAlert: ({ message, type }) => { console.log(`Alert: ${message} - Type: ${type}`); }, updateIsPollModalVisible: (isVisible) => { console.log('Poll modal visibility:', isVisible); },});
Handles the voting process for a poll.
Param: options
The options for handling the vote.
Param: options.pollId
The ID of the poll.
Param: options.optionIndex
The index of the selected option.
Param: options.socket
The socket instance for communication.
Param: options.showAlert
Optional function to show alerts.
Param: options.member
The member who is voting.
Param: options.roomName
The name of the room where the poll is conducted.
Param: options.updateIsPollModalVisible
Function to update the visibility of the poll modal.
Returns
A promise that resolves when the vote is handled.
Throws
Will log an error message if there is an issue submitting the vote.
Example