Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera uno-de-piera/User.ts Secret
Created Jan 21, 2018

Embed
What would you like to do?
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/of';
class User {
userObservable() {
return Observable.of([{name: 'Iparra'}])
.map(user => user[0])
.catch(error => Observable.throw(err));
}
}
let user = new User();
let userObservable = user.userObservable();
userObservable.subscribe(
result => {
console.log(result); //[{name: 'Iparra'}]
},
error => {
console.log(error);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.