diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 4c55215..9bef267 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -37,9 +37,9 @@ export class AppComponent {
const confirm$ = this.confirmDialogService.openConfirmDialog();
confirm$.asObservable().pipe(
take(1),
- switchMap(confirm => confirm ? this.dataService.getData() : EMPTY)
+ switchMap(confirm => confirm ? this.dataService.mockRequest(true, {status: 200}) : this.dataService.mockRequest(false, {status: 400}))
).subscribe(
- (data) => alert(data)
+ (data) => console.log(data)
);
}
diff --git a/src/app/components/confirm-dialog/confirm-dialog.component.html b/src/app/components/confirm-dialog/confirm-dialog.component.html
index 1e9b1fb..32a26fe 100644
--- a/src/app/components/confirm-dialog/confirm-dialog.component.html
+++ b/src/app/components/confirm-dialog/confirm-dialog.component.html
@@ -5,6 +5,6 @@
{{ data?.title }}
{{ data?.message }}
-
-
+
+
diff --git a/src/app/services/data.service.spec.ts b/src/app/services/data.service.spec.ts
new file mode 100644
index 0000000..1a319bd
--- /dev/null
+++ b/src/app/services/data.service.spec.ts
@@ -0,0 +1,16 @@
+/* tslint:disable:no-unused-variable */
+
+import { TestBed, async, inject } from '@angular/core/testing';
+import { DataService } from './data.service';
+
+describe('Service: Data', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [DataService]
+ });
+ });
+
+ it('should ...', inject([DataService], (service: DataService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/app/services/data.service.ts b/src/app/services/data.service.ts
new file mode 100644
index 0000000..e99a544
--- /dev/null
+++ b/src/app/services/data.service.ts
@@ -0,0 +1,21 @@
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class DataService {
+
+ constructor() { }
+
+ mockRequest(data: boolean, options: ResponseInit, sleep = 200) {
+ const response = new Response(JSON.stringify(data), options);
+
+ return new Observable((subscriber) => {
+ setTimeout(() => {
+ options.status < 400 ? subscriber.next(response) : subscriber.error(response);
+ }, sleep);
+ });
+ }
+
+}