Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Manually trigger in-memory-web-api #128

@winnemucca

Description

@winnemucca

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions