All files / tools/src/store/SynchronizerManager destroySynchronizer.ts

0% Statements 0/6
0% Branches 0/2
0% Functions 0/2
0% Lines 0/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                                   
import { state } from '../state';
 
// Synchronizers are a bit more tenacious. We need to make sure we remove
// any attached events
// We should probably just have a destroySynchronizer call
// then use getByX to allow versatility in how we can call destroy
 
/**
 * Destroy a synchronizer by its ID.
 * @param synchronizerId - The id of the synchronizer to destroy.
 */
function destroySynchronizer(synchronizerId: string): void {
  const synchronizerIndex = state.synchronizers.findIndex(
    (sync) => sync.id === synchronizerId
  );
 
  if (synchronizerIndex > -1) {
    const synchronizer = state.synchronizers[synchronizerIndex];
 
    synchronizer.destroy();
    state.synchronizers.splice(synchronizerIndex, 1);
  }
}
 
export default destroySynchronizer;