forked from angular/in-memory-web-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
in-memory-web-api.module.js
45 lines (45 loc) · 1.95 KB
/
in-memory-web-api.module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Injector, NgModule } from '@angular/core';
import { XHRBackend } from '@angular/http';
import { InMemoryBackendConfig, InMemoryBackendService, InMemoryDbService } from './in-memory-backend.service';
// AoT requires factory to be exported
export function inMemoryBackendServiceFactory(injector, dbService, options) {
var backend = new InMemoryBackendService(injector, dbService, options);
return backend;
}
export var InMemoryWebApiModule = (function () {
function InMemoryWebApiModule() {
}
/**
* Prepare in-memory-web-api in the root/boot application module
* with class that implements InMemoryDbService and creates an in-memory database.
*
* @param {Type} dbCreator - Class that creates seed data for in-memory database. Must implement InMemoryDbService.
* @param {InMemoryBackendConfigArgs} [options]
*
* @example
* InMemoryWebApiModule.forRoot(dbCreator);
* InMemoryWebApiModule.forRoot(dbCreator, {useValue: {delay:600}});
*/
InMemoryWebApiModule.forRoot = function (dbCreator, options) {
return {
ngModule: InMemoryWebApiModule,
providers: [
{ provide: InMemoryDbService, useClass: dbCreator },
{ provide: InMemoryBackendConfig, useValue: options },
]
};
};
InMemoryWebApiModule.decorators = [
{ type: NgModule, args: [{
// Must useFactory for AoT
// https://github.com/angular/angular/issues/11178
providers: [{ provide: XHRBackend,
useFactory: inMemoryBackendServiceFactory,
deps: [Injector, InMemoryDbService, InMemoryBackendConfig] }]
},] },
];
/** @nocollapse */
InMemoryWebApiModule.ctorParameters = function () { return []; };
return InMemoryWebApiModule;
}());
//# sourceMappingURL=in-memory-web-api.module.js.map