Skip to content

Commit

Permalink
Merge pull request #31 from danil-z/master
Browse files Browse the repository at this point in the history
Added patch method of sails.io
  • Loading branch information
joeherold authored May 15, 2018
2 parents e12e87e + 1314cfb commit cb20f57
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The following methods are implemented in the SailsService and will always return
- get(path,data):Observable
- post(path,data):Observable
- put(path,data):Observable
- patch(path,data):Observable
- delete(path,data):Observable
- request(options):Observable
- on(eventEntity):Observable
Expand Down
37 changes: 37 additions & 0 deletions lib/sails.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,43 @@ export class SailsService {
return subject.asObservable();
}

/**
*
* @param url
* @param data
* @return {Observable<T>}
*/
patch(url, data?: any): Observable<any> {
let self = this;
let subject = new Subject();

this.zone.runOutsideAngular(() => {
this._io.patch(url, data, (resData, jwres: IJWRes) => {
if (io.sails.environment != "production" && self.silent !== true) {
console.log("patch::data", resData);
console.log("patch:jwr", jwres);
}
if (jwres.statusCode < 200 || jwres.statusCode >= 400) {
subject.error({
data: resData,
statusCode: jwres.statusCode,
response: jwres,
error: jwres.error
})
} else {
//subject.next(resData);
this.zone.run(() => subject.next({
data: resData,
statusCode: jwres.statusCode,
response: jwres
}));
}
subject.complete();
})
});
return subject.asObservable();
}

/**
*
* @param url
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular2-sails",
"version": "0.2.8",
"version": "0.2.9",
"description": "An angular module for using the sails socket.io api in angular2 (@angular) with webpack and AoT compilation",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cb20f57

Please sign in to comment.