Skip to content

Instantly share code, notes, and snippets.

@MarsiBarsi
Created March 29, 2021 17:20
Show Gist options
  • Save MarsiBarsi/057af55ad7f457b7bfc6edd81b9cf081 to your computer and use it in GitHub Desktop.
Save MarsiBarsi/057af55ad7f457b7bfc6edd81b9cf081 to your computer and use it in GitHub Desktop.
@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