import { ChangeDetectionStrategy, Component } from '@angular/core'; import { AsyncPipe, DatePipe } from '@angular/common'; import { map, startWith, switchMap } from 'rxjs'; import { EventDatesPipe } from '@/core/pipes/event-dates.pipe'; import { UnixTimePipe } from '@/core/pipes/unix-time.pipe'; import { injectCatalogsService } from '@/core/services/catalogs.service'; import { injectWebsocketService, WSEvents } from '@/core/services/websocket.service'; @Component({ standalone: true, selector: 'app-schedule', templateUrl: './schedule.component.html', styleUrls: ['./schedule.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, imports: [AsyncPipe, EventDatesPipe, UnixTimePipe], providers: [DatePipe], }) export class ScheduleComponent { private catalogServ = injectCatalogsService(); private listenSchedule$ = injectWebsocketService() .listen(WSEvents.SCHEDULE, ['schedule_print']) .pipe(startWith(true)); schedule$ = this.listenSchedule$.pipe( switchMap(() => this.catalogServ.getSchedule()), map((schedule) => schedule[0]) ); dates$ = this.listenSchedule$.pipe(switchMap(() => this.catalogServ.getEventDates())); }