Skip to content

Instantly share code, notes, and snippets.

@jagomf
Last active September 29, 2018 17:10
Show Gist options
  • Save jagomf/68ec2693db26a54096e025ebb13b66c9 to your computer and use it in GitHub Desktop.
Save jagomf/68ec2693db26a54096e025ebb13b66c9 to your computer and use it in GitHub Desktop.
Alternate method of returning a subscription in an Angular service
getResultFromRemote(): Subject<string> {
const subs = new Subject<string>();
this.http.get('http://localhost/service')
.subscribe((res) => {
subs.next(res);
}, (err) => {
subs.error(res);
});
return subs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment