Introduce the use of EventTarget interface #3

Merged
jsheunis merged 1 commit from events into main 2025-03-12 22:52:21 +00:00

1 commit

Author SHA1 Message Date
364146ce42 Introduce the use of EventTarget interface
This is to address the problem of knowing when a stream has completed.
When loading RDF, the io module's 'readRDF' function returns a stream
which runs asynchronously. It should either be wrapped in a promise on
fully resolved before the surrounding application can access to fully
loaded RDF data, or it could make use of event handling. Since the former
would introduce delays by holding up the full process stream, this commit
makes use of JS-native event handling by making RdfDataset class extend
the EventTarget interface. It now emits events for prefix, prefixesLoaded,
quad, and graphLoaded. Applications that import this functionality from
shacl-tulip should add event listeners to the relevant dataset before
running the dataset.loadRDF function.

The associated tests are updated accordingly, and the READMe as well.
2025-03-12 23:49:28 +01:00