Subscribing to diagnostic messages raised by linter

Hi,
We have been using codemirror in a text editor for a custom language, and have implemented linter to show error markers for any error as the user types into the text editor. When the user is satisfied with the typed in query, they can click on Execute button to execute it.

This feature is well received and there is an enhancement we are hoping to receive help on. The enhancement is to

  1. Enable the Execute button when typed in query is valid
  2. Disable the Execute button when the typed query has errors

Is there an event that can be raised when errors are detected by linter, or the view/state objects that can be subscribed to, to enable/disable the button?

Any help or pointer will be greatly appreciated.

Thank you
~S

You can check transactions for the setDiagnosticsEffect to see when the diagnostics are reset. Or use diagnosticCount to see whether a given state has active diagnostics.

Thank you Marijn. How to check transactions, just need a bit more help to understand this.

To give a background:
The structure of objects and their initialization direction is as shown below -
Container (has editor, execute button) => CM6 Editor => Linter (extension)

In this flow how do I check for transactions?

Thank you!
~S

Depends on what you want to do with them. If you want to run some imperative code in response to them, configure your editor with an update listener. If you want to track something inside the editor state, the update method of a state field would be more appropriate.

Thank you Marijn, let me try this out.

Appreciate your prompt response!

Regards
~S