Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from avatao/develop
Browse files Browse the repository at this point in the history
Getting ready to publish
  • Loading branch information
MrBlaise authored Jun 20, 2017
2 parents 4d45790 + 7a50eb6 commit e955ccf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ yarn-error.log*

node_modules/
.idea/
dist/
dist/

**/.DS_Store
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.0.0-alpha.3 / 2017-06-20
==================

* First published version
* Library is INCOMPLETE and will not work properly with angular yet

1.0.0-alpha.2 / 2017-06-20
==================

Expand Down
6 changes: 6 additions & 0 deletions lib/models/angular-collection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ import {AngularItem} from './angular-item.model';
import {AngularLink} from './angular-link.model';
import {AngularQuery} from './angular-query.model';
import {AngularTemplate} from './angular-template.model';
import {Http} from '@angular/http';

export class AngularCollection extends CollectionBase {

public static httpService: Http;

constructor(collection: CollectionJSON) {
if (typeof AngularCollection.httpService === 'undefined') {
throw new Error('Please configure the HTTP service -> AngularCollection.httpService')
}
super(collection);
}

Expand Down
27 changes: 1 addition & 26 deletions lib/models/angular-link.model.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
import {ReflectiveInjector} from '@angular/core';
import {
BaseRequestOptions,
BaseResponseOptions,
BrowserXhr,
ConnectionBackend,
CookieXSRFStrategy,
Http,
RequestOptions,
ResponseOptions,
XHRBackend,
XSRFStrategy,
} from '@angular/http';
import {Collection, LinkJSON} from 'collection-json-base/interfaces';
import {LinkBase} from 'collection-json-base/models';
import 'rxjs/add/operator/map';
Expand All @@ -20,23 +7,11 @@ import {AngularCollection} from './angular-collection.model';

export class AngularLink extends LinkBase {

private http: Http;

constructor(link: LinkJSON) {
super(link);
const injector = ReflectiveInjector.resolveAndCreate([
Http,
BrowserXhr,
{provide: RequestOptions, useClass: BaseRequestOptions},
{provide: ResponseOptions, useClass: BaseResponseOptions},
{provide: ConnectionBackend, useClass: XHRBackend},
{provide: XSRFStrategy, useFactory: () => new CookieXSRFStrategy()},
]);

this.http = injector.get(Http);
}

public follow(): Observable<Collection> {
return this.http.get(this.href).map((response) => new AngularCollection(response.json().collection));
return AngularCollection.httpService.get(this.href).map((response) => new AngularCollection(response.json().collection));
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "collection-json-angular",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"main": "index.js",
"types": "index.d.ts",
"description": "Implementation of the collection-json.ts library for Angular",
Expand All @@ -12,7 +12,6 @@
"pack": "npm run build && npm run copy && cd dist && npm pack",
"upload": "npm run build && npm run copy && cd dist && npm publish"
},
"private": true,
"repository": {
"type": "git",
"url": "git+https://github.com/avatao/collection-json-angular.git"
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"noImplicitAny": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,

"target": "es5",
"lib": ["es2015", "dom"],
Expand Down

0 comments on commit e955ccf

Please sign in to comment.