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 { TextPipe } from '../text.pipe';
|
||||||
import { HotelService } from './Parent/services/hotel.service';
|
import { HotelService } from './Parent/services/hotel.service';
|
||||||
import { inject } from '@angular/core';
|
import { inject } from '@angular/core';
|
||||||
import { filter, from, last, map, Observable, range, scan, tap, toArray } from 'rxjs';
|
import { filter, from, map, Observable, range, tap, toArray } from 'rxjs';
|
||||||
|
|
||||||
interface User {
|
|
||||||
name: string;
|
|
||||||
age: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -25,35 +20,15 @@ export class AppComponent {
|
|||||||
public hotelService: HotelService = inject(HotelService);
|
public hotelService: HotelService = inject(HotelService);
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
const stream: Observable<number | string> = from([5, 1, 2, 12, 5, 14, 17, 5, "testing"]);
|
||||||
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);
|
|
||||||
|
|
||||||
stream.pipe(
|
stream.pipe(
|
||||||
filter((user) => user.age > 18),
|
filter((value) => typeof value === "number"),
|
||||||
scan((acc, user) => acc + user.age, 0),
|
tap((value) => console.log("Zahl:" + value)),
|
||||||
map((ageSum, index) => ageSum / (index + 1)),
|
filter((value: number) => value % 2 === 0),
|
||||||
last(),
|
tap((value) => console.log("Gerade Zahl: " + value)),
|
||||||
|
toArray(),
|
||||||
).subscribe(console.log);
|
).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() {
|
public test() {
|
||||||
|
Loading…
Reference in New Issue
Block a user