feat(kida): export child to build custom child signals - #250
Merged
Conversation
`child` is the primitive behind `atKey` and `atIndex`: a signal for a property of a parent signal with a custom writer, writable when the parent is writable and a computed otherwise. The store docs describe it as public, but it lived only in `internals`, so `import { child } from '@nano_kit/store'` did not resolve. It is now exported from `kida`, and through it from `@nano_kit/store`. The docs example with a dynamic key types the key signal as the union of keys, which is what `child` requires.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #250 +/- ##
=======================================
Coverage 83.33% 83.33%
=======================================
Files 98 98
Lines 2556 2556
Branches 551 551
=======================================
Hits 2130 2130
Misses 314 314
Partials 112 112 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Why
The Child Signals section of the store low-level page documents
child($parent, key, setValue), butchildlived only inpackages/kida/src/internalsand was not exported fromkidaor@nano_kit/store, so the documented import did not resolve. The public helpers built on it,atKeyandatIndex, are exported and covered by the Advanced page;childis the primitive for custom writers.What
packages/kida/src/child.tsre-exportsinternals/child.js, followinglifecycle.ts, andindex.tsexports it.@nano_kit/storepicks it up throughexport * from 'kida'.signal<'a' | 'b'>('a');childconstrains the key tokeyof P, so anAccessor<string>is rejected.Checks
@nano_kit/storeexports, including the expected errors for an untyped key and for writing a readonly child.oxlint,tsc --noEmitandvitest run(87 tests) inpackages/kidapass;childkeeps its owninternals/child.spec.ts.size-limitof every package that has it pass with unchanged limits:childwas already bundled throughatKeyandatIndex.