I'm trying to figure out how to create a function that will continue running until a specific event, such as mousemove or mouseup, occurs. Here's an example of what I have in mind:
@HostListener('window:mousedown', ['$event'])
onMouseDown(): void {
while (true) {
// do stuff
if(mouseUpEvent || mouseMoveEvent) { // <-- how can I stop the loop when either mouseUp or mouseMove happens?
return;
}
}
}
@HostListener('window:mouseup', ['$event'])
onMouseUp() : void {
// do stuff
}
@HostListener('window:mousemove', ['$event'])
onMouseMove() : void {
// do stuff
}