I'm developing a codeshare app with monaco. how can i get keyboard event or how can i control when to emit? #3646
-
I'm developing a codeshare app with monaco. Client connect to my broardcast server and use onDidChangeModelContent to listen input. after changed, client send message to server, and server broadcast to all my cilent. After cilient recv message, i use executeEdits function to change the text ,but there is a problem, when using executeEdits func, it will triggle onDidChangeModelContent and send another message to server, that will make a endless loop. So i wonder know if there is a event to distinguish keyboard input or message from server, or can i define event myself? client js code below.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@cornorghost Do you find any solution? I'm facing the same problem. |
Beta Was this translation helpful? Give feedback.
-
@cornorghost
|
Beta Was this translation helpful? Give feedback.
@cornorghost
Hey, I found the solution. You can keep some kind of variable to resolve this conflict.
I'm using this with Next.js, so I used the useRef hook.
Here is my code: