Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class AppModule { }
Firstly, create your `Datastore` service:
- Extend the `JsonApiDatastore` class
- Decorate it with `@JsonApiDatastoreConfig`, set the `baseUrl` for your APIs and map your models (Optional: you can set `apiVersion`, `baseUrl` will be suffixed with it)
- Pass the `Http` depencency to the parent constructor.
- Pass the `HttpClient` depencency to the parent constructor.

```typescript
import { JsonApiDatastoreConfig, JsonApiDatastore, DatastoreConfig } from 'angular2-jsonapi';
Expand All @@ -107,7 +107,7 @@ const config: DatastoreConfig = {
@JsonApiDatastoreConfig(config)
export class Datastore extends JsonApiDatastore {

constructor(http: Http) {
constructor(http: HttpClient) {
super(http);
}

Expand Down Expand Up @@ -547,8 +547,8 @@ To lint all `*.ts` files:
$ npm run lint
```

## Additional tools
* Gem for generating the model definitions based on active model serializers: https://github.com/oncore-education/jsonapi_models
## Additional tools
* Gem for generating the model definitions based on active model serializers: https://github.com/oncore-education/jsonapi_models

## Thanks

Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"qs": "^6.5.1"
},
"peerDependencies": {
"@angular/http": ">=4.0.0",
"reflect-metadata": ">=0.1.3",
"rxjs": ">=5.2.0"
},
Expand All @@ -48,7 +47,6 @@
"@angular/compiler": "^4.4.3",
"@angular/compiler-cli": "^4.4.3",
"@angular/core": "^4.4.3",
"@angular/http": "^4.4.3",
"@angular/platform-browser": "^4.4.3",
"@angular/platform-browser-dynamic": "^4.4.3",
"@angular/platform-server": "^4.4.3",
Expand Down
13 changes: 4 additions & 9 deletions src/models/json-api.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
AUTHOR_CREATED, AUTHOR_UPDATED, getAuthorData, getIncludedBooks, BOOK_TITLE, BOOK_PUBLISHED, CHAPTER_TITLE
} from '../../test/fixtures/author.fixture';
import { Book } from '../../test/models/book.model';
import { Http, BaseRequestOptions, ConnectionBackend } from '@angular/http';
import { MockBackend } from '@angular/http/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { Datastore } from '../../test/datastore.service';
import { Chapter } from '../../test/models/chapter.model';

Expand All @@ -18,14 +17,10 @@ describe('JsonApiModel', () => {
beforeEach(() => {

TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
],
providers: [
{
provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
return new Http(backend, defaultOptions);
}, deps: [MockBackend, BaseRequestOptions]
},
MockBackend,
BaseRequestOptions,
Datastore
]
});
Expand Down
5 changes: 2 additions & 3 deletions src/models/json-api.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Headers } from '@angular/http';
import find from 'lodash-es/find';
import includes from 'lodash-es/includes';
import { Observable } from 'rxjs/Observable';
Expand Down Expand Up @@ -198,10 +197,10 @@ export class JsonApiModel {
_.extend(peek, data.attributes);
return peek;
}

const newObject: T = new modelType(this._datastore, data);
this._datastore.addToStore(newObject);

return newObject;
}
}
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { PROVIDERS } from './providers';

@NgModule({
providers: [PROVIDERS],
exports: [HttpModule]
exports: [HttpClientModule]
})
export class JsonApiModule {
}
Loading