feat(challenge7): reorganisation

This commit is contained in:
thomas
2022-11-23 09:51:59 +01:00
parent cc1c6e8b26
commit ca86f5558b
29 changed files with 355 additions and 32 deletions

View File

@@ -0,0 +1 @@
export * from './lib/push.service';

View File

@@ -0,0 +1,32 @@
import {
Push,
randStudent,
randTeacher,
} from '@angular-challenges/ngrx-notification/model';
import { Injectable } from '@angular/core';
import { BehaviorSubject, tap, timer } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class PushService {
private notificationSubject = new BehaviorSubject<Push | undefined>(
undefined
);
notification$ = this.notificationSubject.asObservable();
init() {
this.startTeacherNotification();
this.startStudentNotification();
}
private startTeacherNotification() {
timer(0, 4000)
.pipe(tap(() => this.notificationSubject.next(randTeacher())))
.subscribe();
}
private startStudentNotification() {
timer(1000, 3000)
.pipe(tap(() => this.notificationSubject.next(randStudent())))
.subscribe();
}
}

View File

@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';