Skip to content

Commit fdac247

Browse files
author
Mayur Patel
committed
Updated the files to have sharable observers
1 parent 9a05bf7 commit fdac247

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

angular2-rest.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

angular2-rest.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,13 @@ function methodBuilder(method: number) {
255255
if (descriptor.isJSON) {
256256
observable = observable.map(res => res.json());
257257
}
258+
259+
// share the observable with multiple subscribers to avoid duplicate HTTP calls.
260+
observable = observable.share()
258261

259262
// intercept the response
260263
observable = this.responseInterceptor(observable);
261-
var apiCall = observable.share()
262-
apiCall.subscribe((success) => {
263-
console.log(success);
264-
}, (error) => {
265-
console.log(success);
266-
})
264+
267265
return observable;
268266
};
269267

0 commit comments

Comments
 (0)