This repository was archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 229
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Manually trigger in-memory-web-api #128
Copy link
Copy link
Closed
Description
I am seeing that it is very straightforward to enable it is very straight forward to enable/disable in-memory-web-api according to your documentation. I have been playing with scenarios in which the tester can enable/disable certain mock services from a dropdown modal.
I have not been able to subscribe to the service from my component.
export class InMemPatientService implements InMemoryDbService {
createDb() {
const patients = [
{
id: 1,
patient: "Adewumi, Anice (56, F)",
facility: "Brighton",
datesValid: "07/07/17 - 07/07/18",
typeD: "Tx Hemo (CHG)",
order: "Frequency 3 times per week; Treatment Time 4 hours 10 minutes per week (250)"
},
{
id:2,
patient: "Bowman, Jackson (56, M)",
facility: "Brighton",
datesValid: "06/07/17 - 07/07/18",
typeD: "Tx Hemo (CHG)",
order: "Frequency 3 times per week; Treatment Time 4 hours 10 minutes per week (250)"
}
];
return {patients};
}
}
I was hoping the subscription would be as simple as injecting the service into the component and doing
constructor(private modalService: NgbModal,
private memPatientService: InMemPatientService) {}
runMockServiceCheck() {
if (!this.mockServiceCheck) {
console.log("false");
} else {
this.memPatientService
.createDb()
.subscribe(patients => {
this.patients = patients;
},
error => this.errorMessage = <any>error);
}
}
However, I receive an error
Property 'subscribe' does not exist on type '{ patients: ({ id: number; patient: string; facility: string; datesValid: string; typeD: string; ...'.
This is definitely a stack overflow type question, but I am curious if this is even possible to achieve with the library?
Additionally, I changed my return statement to
return Observable.of({patients}), but this doesn't seems to lose the lose the data in the subscribe.
Metadata
Metadata
Assignees
Labels
No labels