Compares the current active names with the previous active names and triggers an action if there are changes.
The options for comparing active names.
Whether to restart the comparison.
The parameters for the comparison.
Function to get updated parameters.
The current active names.
The previous active names.
Function to update the previous active names.
Function to trigger an action when names change.
A promise that resolves when the comparison is complete.
Will log an error message if an error occurs during the comparison.
const options = { restart: false, parameters: { getUpdatedAllParams: () => { /* Logic to get updated parameters */ }, activeNames: ['Alice', 'Bob'], prevActiveNames: ['Alice', 'Charlie'], updatePrevActiveNames: (names) => { /* Logic to update previous active names */ }, trigger: async (data) => { /* Logic to handle the trigger */ }, },};await compareActiveNamesService.compareActiveNames(options);// If 'Bob' is not in the previous active names, it will trigger the action. Copy
const options = { restart: false, parameters: { getUpdatedAllParams: () => { /* Logic to get updated parameters */ }, activeNames: ['Alice', 'Bob'], prevActiveNames: ['Alice', 'Charlie'], updatePrevActiveNames: (names) => { /* Logic to update previous active names */ }, trigger: async (data) => { /* Logic to handle the trigger */ }, },};await compareActiveNamesService.compareActiveNames(options);// If 'Bob' is not in the previous active names, it will trigger the action.
Compares the current active names with the previous active names and triggers an action if there are changes.
Param: options
The options for comparing active names.
Param: options.restart
Whether to restart the comparison.
Param: options.parameters
The parameters for the comparison.
Param: options.parameters.getUpdatedAllParams
Function to get updated parameters.
Param: options.parameters.activeNames
The current active names.
Param: options.parameters.prevActiveNames
The previous active names.
Param: options.parameters.updatePrevActiveNames
Function to update the previous active names.
Param: options.parameters.trigger
Function to trigger an action when names change.
Returns
A promise that resolves when the comparison is complete.
Throws
Will log an error message if an error occurs during the comparison.
Example