Introduce the use of EventTarget interface #3

Merged
jsheunis merged 1 commit from events into main 2025-03-12 22:52:21 +00:00
jsheunis commented 2025-03-12 22:49:58 +00:00 (Migrated from github.com)

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.

Closes #1

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. Closes #1
Sign in to join this conversation.
No description provided.