-
Notifications
You must be signed in to change notification settings - Fork 0
Projection Signals #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
estherbrunner
wants to merge
6
commits into
main
Choose a base branch
from
feature/projection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
Support optional KeyConfig parameter in createStore to generate stable keys for array items. This allows tracking items across reorders and prevents false change notifications when array structure changes but item identity remains the same.
Replace dual `keyAt` and `indexByKey` Maps with a single `order` array for simpler and more efficient key-to-index tracking. Update `indexByKey` method to `indexOfKey` with consistent return values (-1 for not found). Simplify `current()` to properly handle both array and record stores. Remove unused utility functions `validArrayIndexes` and `recordToArray`.
Documentation and examples for array-like stores with stable keys, which persist through sorting and reordering operations. Includes new store methods `byKey()`, `keyAt()`, `indexOfKey()`, and `splice()`.
Implement Collections in src/collection.ts: - createCollection factory for deriving from stores - Proxy-based array-like interface with computed signals - Key management and event notifications - Read-only enforcement with DuplicateKeyError Rename StoreKeyExistsError to DuplicateKeyError for consistency across both stores and collections. Update system.ts with Notifications and Listener types for standardized event handling across signal types.
| }) | ||
|
|
||
| test('works with array stores using custom string prefix keys', () => { | ||
| const items = createStore(['apple', 'banana', 'cherry'], 'fruit') |
| { id: 'u2', name: 'Bob' }, | ||
| { id: 'u3', name: 'Charlie' }, | ||
| ], | ||
| item => item.id, |
| }) | ||
|
|
||
| test('stable keys persist after sort operations', () => { | ||
| const numbers = createStore([30, 10, 20], 'num') |
| }) | ||
|
|
||
| test('stable keys work with add/remove operations', () => { | ||
| const items = createStore(['first'], 'item') |
| { id: 'item1', count: 5 }, | ||
| { id: 'item2', count: 3 }, | ||
| ], | ||
| item => item.id, |
| }) | ||
|
|
||
| test('keyAt() and indexOfKey() work with custom string prefix keys', () => { | ||
| const items = createStore(['apple', 'banana', 'cherry'], 'fruit') |
| { id: 'bob', name: 'Bob' }, | ||
| { id: 'charlie', name: 'Charlie' }, | ||
| ], | ||
| item => item.id, |
| }) | ||
|
|
||
| test('round-trip consistency: keyAt(indexOfKey(key)) === key', () => { | ||
| const items = createStore(['a', 'b', 'c'], 'item') |
| }) | ||
|
|
||
| test('methods work correctly after multiple operations', () => { | ||
| const items = createStore(['a', 'b'], 'x') |
| }) | ||
|
|
||
| test('collection supports key-based access methods', () => { | ||
| const items = createStore(['a', 'b', 'c'], 'item') |
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.
No description provided.