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

100% Statements 6/6
50% Branches 1/2
100% Functions 2/2
100% Lines 6/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                        1x 1x     1x 1x   1x 1x          
import { state } from '../index';
 
// 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
  );
 
  Eif (synchronizerIndex > -1) {
    const synchronizer = state.synchronizers[synchronizerIndex];
 
    synchronizer.destroy();
    state.synchronizers.splice(synchronizerIndex, 1);
  }
}
 
export default destroySynchronizer;