Skip to content

Commit fff0f1e

Browse files
committed
Updates to readme
1 parent 7c0f21a commit fff0f1e

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,67 @@ One of the biggest, yet relatively unknown performance boosts you will get with
1010

1111
Working demo https://plnkr.co/edit/OgvZ09iYO64VoXHLRGQa?p=preview
1212

13+
## Table of contents:
14+
- [Get Started](#get-started)
15+
- [Installation](#installation)
16+
- [Examples](#examples)
17+
- [Usage](#usage)
18+
- [angular-quickstart](#quickstart)
19+
- [angular-seed](#seed)
1320

14-
```language-javascript
21+
## <a name="get-started"></a> Get Started
22+
23+
### <a name="installation"></a> Installation
24+
25+
You can install this package locally with npm.
26+
27+
```bash
1528
npm install ngx-http-batcher --save
1629
```
30+
31+
### <a name="examples"></a> Examples
32+
You can see a working Plunker here https://plnkr.co/edit/OgvZ09iYO64VoXHLRGQa?p=preview
33+
There isn't much too visually see but you will want to open up the network tab on the dev tools and look for a request will '$batch'. This the the actual batch request for 3 seperate normal http requests.
34+
35+
### <a name="usage"></a> Usage
36+
`NgxHttpBatcherModule` should be registered in the `AppModule` imports. This module relies on the Angular HttpModule so ensure that is also imported.
37+
38+
39+
```javascript
40+
import { BrowserModule } from "@angular/platform-browser";
41+
import { NgModule } from "@angular/core";
42+
import { HttpModule, Http } from "@angular/http";
43+
import { NgxHttpBatcherModule,
44+
HttpBatchConfiguration,
45+
HttpBatchConfigurationCollection,
46+
HttpBatcher } from "ngx-http-batcher";
47+
48+
import { AppComponent } from "./app.component";
49+
50+
export function httpBatchConfigurationFactory() {
51+
return new HttpBatchConfigurationCollection([
52+
new HttpBatchConfiguration({
53+
rootEndpointUrl: "https://my.service.com",
54+
batchEndpointUrl: "https://my.service.com/$batch"
55+
})]);
56+
};
57+
58+
@NgModule({
59+
declarations: [
60+
AppComponent
61+
],
62+
imports: [
63+
BrowserModule,
64+
HttpModule,
65+
NgxHttpBatcherModule
66+
],
67+
providers: [
68+
{ provide: HttpBatchConfigurationCollection, useFactory: httpBatchConfigurationFactory },
69+
{ provide: Http, useClass: HttpBatcher }
70+
],
71+
bootstrap: [AppComponent]
72+
})
73+
export class AppModule { }
74+
```
75+
76+

0 commit comments

Comments
 (0)