mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-12 22:03:03 -05:00
feat(challenge7): reorganisation
This commit is contained in:
1
libs/ngrx-notification/backend/src/index.ts
Normal file
1
libs/ngrx-notification/backend/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './lib/push.service';
|
||||
32
libs/ngrx-notification/backend/src/lib/push.service.ts
Normal file
32
libs/ngrx-notification/backend/src/lib/push.service.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
1
libs/ngrx-notification/backend/src/test-setup.ts
Normal file
1
libs/ngrx-notification/backend/src/test-setup.ts
Normal file
@@ -0,0 +1 @@
|
||||
import 'jest-preset-angular/setup-jest';
|
||||
Reference in New Issue
Block a user