mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-13 06:13:03 -05:00
feat(doc): move race-condition
This commit is contained in:
38
apps/rxjs/race-condition/src/app/app.component.ts
Normal file
38
apps/rxjs/race-condition/src/app/app.component.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
inject,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { take } from 'rxjs';
|
||||
import { TopicModalComponent } from './topic-dialog.component';
|
||||
import { TopicService, TopicType } from './topic.service';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: 'app-root',
|
||||
template: ` <button (click)="openTopicModal()">Open Topic</button> `,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'rxjs-race-condition';
|
||||
dialog = inject(MatDialog);
|
||||
topicService = inject(TopicService);
|
||||
topics: TopicType[] = [];
|
||||
|
||||
ngOnInit(): void {
|
||||
this.topicService
|
||||
.fakeGetHttpTopic()
|
||||
.pipe(take(1))
|
||||
.subscribe((topics) => (this.topics = topics));
|
||||
}
|
||||
|
||||
openTopicModal() {
|
||||
this.dialog.open(TopicModalComponent, {
|
||||
data: {
|
||||
topics: this.topics,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user