You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+79-47Lines changed: 79 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ that emulates CRUD operations over a RESTy API.
7
7
It intercepts Angular `Http` and `HttpClient` requests that would otherwise go to the remote server and redirects them to an in-memory data store that you control.
8
8
9
9
---
10
-
## **v0.4.0 supports `HttpClient`!**
10
+
## **v0.4 supports `HttpClient`!**
11
11
>Release v0.4.0 (8 Sept 2017) is a major overhaul of this library.
12
12
>
13
13
>You don't have to change your existing application _code_ if your app uses this library without customizations.
@@ -105,6 +105,7 @@ Usage:
105
105
```
106
106
107
107
## Basic usage
108
+
108
109
Create an `InMemoryDataService` class that implements `InMemoryDbService`.
109
110
110
111
At minimum it must implement `createDb` which
@@ -129,17 +130,19 @@ export class InMemHeroService implements InMemoryDbService {
129
130
130
131
>This library _currently_ assumes that every collection has a primary key called `id`.
131
132
132
-
Register this module and your data store service implementation in `AppModule.imports`
133
-
calling the `forRoot` static method with this service class and optional configuration object:
133
+
Register your data store service implementation with the `HttpClientInMemoryWebApiModule`
134
+
in your root `AppModule.imports`
135
+
calling the `forRoot` static method with this service class and an optional configuration object:
* The `createDb` method can be synchronous or asynchronous.
176
161
so you can initialize your in-memory database service from a JSON file.
177
162
Return the database object, an observable of that object, or a promise of that object.
178
163
The in-mem web api service calls `createDb` (a) when it handles the _first_`HttpClient` (or `Http`) request and (b) when it receives a `POST resetdb` request.
179
164
180
-
## In-memory web api examples
181
-
The tests (`src/app/*.spec.ts` files) in the [github repo](https://github.com/angular/in-memory-web-api/tree/master/src/app) are a good place to learn how to setup and use this in-memory web api library.
165
+
### Using with the older Angular _Http_ module
166
+
167
+
You can still use the in-memory web api with the older `Http` module.
The `HeroInMemDataOverrideService` class (in `src/app/hero-in-mem-data-override.service.ts`)
392
+
demonstrates a few ways to override methods of the base `HeroInMemDataService`.
361
393
362
-
The tests (see below) exercise these examples.
394
+
The tests ([see below](#testing)) exercise these examples.
363
395
364
396
# Build Instructions
365
397
@@ -425,18 +457,18 @@ The `src/` folder is divided into
425
457
>A real app would reference the in-memory web api node module;
426
458
these tests reference the library source files.
427
459
428
-
The `karma-test-shim.js`add `in-mem` to the list of app folders that SystemJS should resolve.
460
+
The `karma-test-shim.js`adds the `in-mem`folder to the list of folders that SystemJS should resolve.
429
461
430
462
## Rollup
431
463
432
464
The gulp "umd" task runs rollup for tree-shaking.
433
465
434
-
I don't remember it ever working without a lot of warnings.
435
-
In v.0.4.x, updated to v.0.49 ... which required updating of the `rollup.config.js`.
466
+
I don't remember if it ever worked without a lot of warnings.
467
+
The `v0.4.x` release updated to `rollup@0.49`which required updates to the `rollup.config.js`.
436
468
437
-
Still weirdly runs an unspecified`cjs` rollup config first that I can’t find (which produces numerous warnings) before doing the right thing and running the `umd` config.
469
+
Still weirdly runs `cjs` rollup config first that I can’t find (which produces numerous warnings) before doing the right thing and running the `umd` config.
438
470
439
-
Also does not work if follow instructions and use the `output` property of `rollup.config.js`; does work when config it “wrong” and put the options in the root.
471
+
Also does not work if you follow instructions and use the `output` property of `rollup.config.js`; does work when configure it “wrong” and put the options in the root.
0 commit comments