Skip to content

Commit cb20f57

Browse files
authored
Merge pull request #31 from danil-z/master
Added patch method of sails.io
2 parents e12e87e + 1314cfb commit cb20f57

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ The following methods are implemented in the SailsService and will always return
9797
- get(path,data):Observable
9898
- post(path,data):Observable
9999
- put(path,data):Observable
100+
- patch(path,data):Observable
100101
- delete(path,data):Observable
101102
- request(options):Observable
102103
- on(eventEntity):Observable

lib/sails.service.ts

+37
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,43 @@ export class SailsService {
419419
return subject.asObservable();
420420
}
421421

422+
/**
423+
*
424+
* @param url
425+
* @param data
426+
* @return {Observable<T>}
427+
*/
428+
patch(url, data?: any): Observable<any> {
429+
let self = this;
430+
let subject = new Subject();
431+
432+
this.zone.runOutsideAngular(() => {
433+
this._io.patch(url, data, (resData, jwres: IJWRes) => {
434+
if (io.sails.environment != "production" && self.silent !== true) {
435+
console.log("patch::data", resData);
436+
console.log("patch:jwr", jwres);
437+
}
438+
if (jwres.statusCode < 200 || jwres.statusCode >= 400) {
439+
subject.error({
440+
data: resData,
441+
statusCode: jwres.statusCode,
442+
response: jwres,
443+
error: jwres.error
444+
})
445+
} else {
446+
//subject.next(resData);
447+
this.zone.run(() => subject.next({
448+
data: resData,
449+
statusCode: jwres.statusCode,
450+
response: jwres
451+
}));
452+
}
453+
subject.complete();
454+
})
455+
});
456+
return subject.asObservable();
457+
}
458+
422459
/**
423460
*
424461
* @param url

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-sails",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "An angular module for using the sails socket.io api in angular2 (@angular) with webpack and AoT compilation",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)