feat(events): change notifications on DatasetWrapper (on/off) - #94
Draft
jeswr wants to merge 1 commit into
Draft
Conversation
DatasetWrapper now layers @jeswr/eventful-dataset's EventfulDatasetCore over the wrapped dataset (constructor signature unchanged; write-through storage preserved) and exposes on(listener)/off(listener) so consumers can observe effective additions and deletions - whether performed directly or through mapped properties, Set mappings, or named graph views sharing the same eventful core. Adds the IDatasetChangeListener/ChangeEvent types to the public surface and ports the dataset_events test slices from rdfjs#73. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 6, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds change notifications to
DatasetWrapper: consumers can now observe every effective mutation of the underlying data withon(listener)/off(listener).What it does
DatasetWrapperstill accepts any RDF/JSDatasetCore(constructor signature unchanged) and now internally ensures an eventful layer over it (ensureEventfulDatasetCore). The passed dataset remains the single place of storage — mutations write through to it, so external references to it observe all changes.DatasetWrapper.on(listener)andDatasetWrapper.off(listener), plus the exportedIDatasetChangeListener/ChangeEventtypes. Listeners are called synchronously with("add" | "delete", quad).Quad.equals): adding an already-contained quad or deleting an absent one emits nothing.DatasetWrapper.add/delete, events fire uniformly for:add/deletecalls,RequiredAs/OptionalAsmappings (delete of the previous quads, then add — assignments do not deduplicate; clearing an optional property emits only deletes),Sets produced bySetFrom(add/delete/clear),named(...), which share the same eventful core.Dependency
This introduces the package's first runtime dependency: the event-emitting
DatasetCorelives in@jeswr/eventful-datasetrather than being copied in-repo. It is currently pinned as agithub:branch dependency while it is staged; it would move to a released npm version (or wherever the group prefers it to live) before this leaves draft. Flagging it explicitly since"dependencies": {}was a visible property of this package.Relation to #73
Supersedes the events slice of #73 (Omnibus): the
DatasetWrapper.on/offwiring, theNotificationsDatasetCoreconcern, and the dataset events tests. TheEventEmitter/notifying-dataset implementation now comes from the foundation package instead of the in-reposrc/EventEmitter.ts+src/dataset/NotifyingDatasetCore.tscopies.Deliberately not included from #73 (left to their own slices): the
Triple/default-graph restriction, thedatasetFactoryconstructor parameter,GraphScopedDataset/ProjectedDataset, and all of the async (AsyncDatasetCore) work. Nosize/matchsemantics change here.Tests
test/unit/dataset_events.test.ts— direct add/delete notifications, effective-change filtering, listener bookkeeping (off, double-subscribe, multiple listeners), and wrapper-driven events for required/optional/typed properties and Set mappings, on the existing Parent/Child fixtures.test/unit/dataset_events_examples.test.ts— the JSDoc-style examples as executable tests: observing aSetFrom-backed children set (live views, per-item events) and an optional email field.npm i && npx tsc && npm test && npx typedoc && npm audit --omit=dev --audit-level=moderateall pass locally (150 tests, 0 fail; typedoc warnings unchanged frommain).