Created
May 8, 2022 14:42
-
-
Save lorenzojkrl/74b1d4d0451fa98c4e74a1f28a029722 to your computer and use it in GitHub Desktop.
Data Manipulation using the RxJS tap operator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { TodoService } from './todo.service'; | |
import { map } from 'rxjs/operators'; | |
interface ToDo { | |
userId: number; | |
id: number; | |
title: string; | |
completed: boolean; | |
} | |
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
}) | |
export class AppComponent { | |
data$ = this.todoService.todo$.pipe( | |
map((x: ToDo) => ({ | |
...x, | |
title: x.title + ' and more', | |
})) | |
); | |
constructor(private todoService: TodoService) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment