UNPKG

mediasfu-reactnative

Version:
36 lines 1.61 kB
/** * Handles the event when a user joins the waiting room, displaying a notification and updating the count of waiting requests. * * @param {Object} options - The options for managing the user waiting event. * @param {string} options.name - The name of the user joining the waiting room. * @param {Function} [options.showAlert] - Optional function to display an alert/notification. * @param {number} options.totalReqWait - The current total count of requests waiting. * @param {Function} options.updateTotalReqWait - Function to update the total number of requests in the waiting room. * @returns {Promise<void>} A promise that resolves when the waiting event is fully handled. * * @example * ```typescript * const options = { * name: "John Doe", * showAlert: (alert) => console.log(alert.message), * totalReqWait: 3, * updateTotalReqWait: (total) => console.log("Updated total:", total), * }; * * userWaiting(options) * .then(() => console.log("User waiting handled")) * .catch((error) => console.error("Error:", error)); * ``` */ export const userWaiting = async ({ name, showAlert, totalReqWait, updateTotalReqWait, }) => { // Display an alert/notification about the user joining the waiting room showAlert === null || showAlert === void 0 ? void 0 : showAlert({ message: `${name} joined the waiting room.`, type: 'success', duration: 3000, }); // Update the total number of requests waiting in the waiting room const totalReqs = totalReqWait + 1; updateTotalReqWait(totalReqs); }; //# sourceMappingURL=userWaiting.js.map