Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. @Component({
  2. selector: 'commits-with-service',
  3. templateUrl: './commits-with-service.component.html',
  4. styleUrls: ['./commits-with-service.component.scss'],
  5. changeDetection: ChangeDetectionStrategy.OnPush
  6. })
  7. export class CommitsWithServiceComponent {
  8.  
  9. commits$: Observable<Commit[]> = of([]);
  10. failures: Failure[] = [];
  11.  
  12. constructor(private commitsService: CommitsService) { }
  13.  
  14. search(username: string) {
  15. this.commits$ = this.commitsService.readCommitsByUsername(username)
  16. .pipe(
  17. tap(this.resetFailure),
  18. catchError(this.handleFailure)
  19. );
  20. }
  21.  
  22. resetFailure = () => {
  23. this.failures = [];
  24. }
  25.  
  26. handleFailure = () => {
  27. this.failures = [new Failure('Oh dear! Something went wrong, we are sorry!')];
  28. return of([]);
  29. };
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement