Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let keydownBufferSubject$: Subject<frontendNote> = new Subject()
- const keydowns$ = fromEvent(document, "keydown").pipe(
- filter((val: any) => val.key !== "Meta")
- )
- this.keydowns$ = keydowns$.subscribe((_) => {
- // console.log(_)
- keydownBufferSubject$.next(this.activeNote)
- })
- const keydownBuffer$ = keydownBufferSubject$.pipe(
- scan<any, Array<frontendNote>>((acc, val) => {
- return [...acc, val]
- }, []),
- debounce((_) => timer(500)),
- take(1),
- mergeAll(),
- distinctUntilKeyChanged("id"),
- repeat()
- )
- keydownBuffer$.subscribe((previouslyActiveNote) => {
- this.requests.notes.save.send(previouslyActiveNote)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement