Skip to content

Extract the common parts of the object-specific stores into a base class - #77

Merged
chelproc merged 1 commit into
mainfrom
store-base
Nov 14, 2026
Merged

chelproc merged 1 commit into
mainfrom
store-base

Conversation

@chelproc

Copy link
Copy Markdown
Contributor

Extract the parts shared by the five object-specific stores (components, nodes, component pins, node pins, and connections) into a new base class CCBaseStore in src/store/base.ts. This is a first step toward a GC-like mechanism that cleans up objects whose references are gone, which needs a single place that owns the objects of every store.

CCBaseStore holds:

  • the reference to the root store (#store in each store becomes the protected store)
  • the map of objects (#components, #nodes, #pins, #nodePins, and #connections become the protected objects)
  • get and getMany, which were identical in every store
  • the abstract mount
  • CCBaseStoreEvents, the didRegister, willUnregister, and didUnregister events that each store's event type now extends

register, unregister, and import stay in each store, as they still differ: unregister takes a single id in some stores and an array in others, and import bypasses register in the component pin and connection stores. No behavior changes.

Validation:

  • npm run type-check
  • npm run check
  • npm test -- --run
  • npm run build

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with  Cloudflare Pages  Cloudflare Pages

Latest commit: b7a8024
Status: ✅  Deploy successful!
Preview URL: https://c5f41d34.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev
Branch Preview URL: https://store-base.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev

View logs

@chelproc
chelproc merged commit bfb8163 into main Nov 14, 2026
2 checks passed
@chelproc
chelproc deleted the store-base branch November 14, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant