Created
March 29, 2021 17:20
-
-
Save MarsiBarsi/057af55ad7f457b7bfc6edd81b9cf081 to your computer and use it in GitHub Desktop.
This file contains 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
@Component({}) | |
export class AppComponent { | |
readonly noneMessage = "nothing"; | |
readonly selectSeat$ = new Subject<number>(); | |
readonly selectedMessage$ = this.selectSeat$.pipe( | |
scan(registerSeats, new Set<number>()), | |
startWith(new Set<number>()), | |
map(set => (set.size ? Array.from(set).join(", ") : this.noneMessage)), | |
share() | |
); | |
readonly cost$ = this.selectSeat$.pipe( | |
reduce(registerSeats, new Set()), | |
map(selected => selected.size * 3) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment