Skip to content

Instantly share code, notes, and snippets.

@lorenzojkrl
Created May 8, 2022 14:42
Show Gist options
  • Save lorenzojkrl/74b1d4d0451fa98c4e74a1f28a029722 to your computer and use it in GitHub Desktop.
Save lorenzojkrl/74b1d4d0451fa98c4e74a1f28a029722 to your computer and use it in GitHub Desktop.
Data Manipulation using the RxJS tap operator
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