All files / Api/ResumePoints/Streams createResumePointsIntervalStream.js

100% Statements 12/12
100% Branches 0/0
100% Functions 5/5
100% Lines 7/7

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 27 28 29 301x 1x               6x             2x 2x             14x 10x        
import { interval } from 'rxjs';
import {
    filter,
    map,
    switchMap,
    withLatestFrom,
    takeUntil,
} from 'rxjs/operators';
 
const createResumePointIntervalStream = (
    playerPlaybackStoreUpdate$,
    resumePointsStoreUpdate$,
    scheduler
) =>
    resumePointsStoreUpdate$
        .pipe(
            filter(({ isEnabled }) => isEnabled),
            switchMap(({ updateIntervalMs }) =>
                interval(updateIntervalMs, scheduler)
                    .pipe(
                        takeUntil(resumePointsStoreUpdate$)
                    )
            ),
            withLatestFrom(playerPlaybackStoreUpdate$),
            filter(([, { isPlaying }]) => isPlaying),
            map(([, { currentTime }]) => currentTime),
        );
 
export default createResumePointIntervalStream;