forked from doubtfire-lms/doubtfire-web
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43de6ea
commit f70ebdc
Showing
2 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {Observable, interval, shareReplay} from 'rxjs'; | ||
|
||
// we have a service so that we can share the same interval observable among multiple subscribers | ||
// simply, all unitCodes will tick over at the same time | ||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class UnitCodeService { | ||
private readonly interval$: Observable<number>; | ||
|
||
constructor() { | ||
// we use shareReplay to share the same interval observable among multiple subscribers | ||
this.interval$ = interval(3000).pipe(shareReplay({bufferSize: 1, refCount: true})); | ||
} | ||
|
||
getInterval(): Observable<number> { | ||
return this.interval$; | ||
} | ||
} |