Compare commits
1 Commits
329cd65b69
...
b3f4317129
Author | SHA1 | Date | |
---|---|---|---|
b3f4317129 |
@ -5,12 +5,7 @@ import { AsyncPipe, UpperCasePipe } from '@angular/common';
|
||||
import { TextPipe } from '../text.pipe';
|
||||
import { HotelService } from './Parent/services/hotel.service';
|
||||
import { inject } from '@angular/core';
|
||||
import { filter, from, last, map, Observable, range, scan, tap, toArray } from 'rxjs';
|
||||
|
||||
interface User {
|
||||
name: string;
|
||||
age: number;
|
||||
}
|
||||
import { filter, from, map, Observable, range, tap, toArray } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -25,35 +20,15 @@ export class AppComponent {
|
||||
public hotelService: HotelService = inject(HotelService);
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
const users = [
|
||||
{ name: "Max", age: 21 },
|
||||
{ name: "Peter", age: 31 },
|
||||
{ name: "Hans", age: 13 },
|
||||
{ name: "Klaus", age: 51 },
|
||||
{ name: "Dieter", age: 1 },
|
||||
{ name: "Jan-Marlon", age: 3 },
|
||||
]
|
||||
|
||||
|
||||
const stream: Observable<User> = from(users);
|
||||
const stream: Observable<number | string> = from([5, 1, 2, 12, 5, 14, 17, 5, "testing"]);
|
||||
|
||||
stream.pipe(
|
||||
filter((user) => user.age > 18),
|
||||
scan((acc, user) => acc + user.age, 0),
|
||||
map((ageSum, index) => ageSum / (index + 1)),
|
||||
last(),
|
||||
filter((value) => typeof value === "number"),
|
||||
tap((value) => console.log("Zahl:" + value)),
|
||||
filter((value: number) => value % 2 === 0),
|
||||
tap((value) => console.log("Gerade Zahl: " + value)),
|
||||
toArray(),
|
||||
).subscribe(console.log);
|
||||
|
||||
// const stream: Observable<number | string> = from([5, 1, 2, 12, 5, 14, 17, 5, "testing"]);
|
||||
|
||||
// stream.pipe(
|
||||
// filter((value) => typeof value === "number"),
|
||||
// tap((value) => console.log("Zahl:" + value)),
|
||||
// filter((value: number) => value % 2 === 0),
|
||||
// tap((value) => console.log("Gerade Zahl: " + value)),
|
||||
// toArray(),
|
||||
//).subscribe(console.log);
|
||||
}
|
||||
|
||||
public test() {
|
||||
|
Loading…
Reference in New Issue
Block a user