Skip to content

Commit

Permalink
add specific event listener examples
Browse files Browse the repository at this point in the history
  • Loading branch information
innerdvations committed Jun 28, 2023
1 parent a58a2f9 commit 08c173c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions docs/docs/docs/01-core/data-transfer/01-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,24 @@ The engine includes a diagnostics reporter which can be used to listen for diagn
Here is an example for creating a diagnostics listener:

```
// your listener
engine.diagnostics.onDiagnostic(async (data: GenericDiagnostic) => {
// handle the diagnostics, for example with custom logging
});
// listener function
const diagnosticListener: DiagnosticListener = (data: GenericDiagnostic) => {
// handle the diagnostics event, for example with custom logging
}
// add a generic listener
engine.diagnostics.onDiagnostic(diagnosticsListener);
// OR
engine.diagnostics.addListener('diagnostic', diagnosticListener);
// add an error listener
engine.diagnostics.addListener('diagnostic.error', diagnosticListener);
// add a warning listener
engine.diagnostics.addListener('diagnostic.warning', diagnosticListener);
// engine/diagnostics.ts - format of the data sent to the listener
// engine/diagnostics.ts
// format of the data sent to the listener
export type GenericDiagnostic<K extends DiagnosticKind, T = unknown> = {
kind: K;
details: {
Expand Down

0 comments on commit 08c173c

Please sign in to comment.