Last active
June 10, 2018 22:06
-
-
Save m1m1s1ku/e52972ad5fdb6a8817186e67aa85ecbf to your computer and use it in GitHub Desktop.
Konami RXJS 6
This file contains hidden or 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
let keyDowns$: Observable<Event | string> = fromEvent(document, 'keyup'); | |
keyDowns$ = keyDowns$.pipe( | |
map((event: KeyboardEvent) => event.code), | |
bufferCount(10, 1), | |
map(codes => codes.join(',')), | |
filter(codes => codes === "ArrowUp,ArrowUp,ArrowDown,ArrowDown,ArrowLeft,ArrowRight,ArrowLeft,ArrowRight,KeyB,KeyQ") | |
) | |
keyDowns$.subscribe(() => { | |
this.setState({admin: !this.state.admin, item: null}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment