Skip to content

Commit

Permalink
hide loading spinner only in between segments, not on the first load
Browse files Browse the repository at this point in the history
  • Loading branch information
ken107 committed Nov 25, 2024
1 parent d8535f4 commit 53077cb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/speech.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ function Speech(texts, options) {
const isLoadingSubject = new rxjs.BehaviorSubject(false)
const isLoading$ = isLoadingSubject.pipe(
rxjs.distinctUntilChanged(),
rxjs.switchMap(yes =>
rxjs.iif(() => yes, rxjs.timer(2000), rxjs.of(0)).pipe(
rxjs.map(() => yes)
)
rxjs.scan((previous$, isLoading) =>
rxjs.iif(() => previous$ && isLoading, rxjs.timer(2000), rxjs.of(0)).pipe(
rxjs.map(() => isLoading)
),
null
),
rxjs.switchAll(),
rxjs.shareReplay({bufferSize: 1, refCount: false})
)

Expand Down

0 comments on commit 53077cb

Please sign in to comment.