import { fromEvent } from "rxjs"; | |
import { debounceTime, map } from "rxjs/operators"; | |
let span = document.querySelector("#span-location"); | |
let button = document.querySelector("#btnStop"); | |
let subscription = fromEvent(document, "mousemove") | |
.pipe( | |
map((e) => { | |
return { x: e.clientX, y: e.clientY }; | |
}), | |
debounceTime(100) | |
) | |
.subscribe((e) => { | |
span.innerHTML = `X: ${e.x} - Y: ${e.y}`; | |
}); | |
button.addEventListener("click", (event) => subscription.unsubscribe()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment