-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(table): support external reactivity binding #6237
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
Draft
riccardoperra
wants to merge
11
commits into
alpha
Choose a base branch
from
feat/native-reactivity
base: alpha
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.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d0221a2
feat(table): support external reactivity binding
riccardoperra 5a5be8b
feat(table): update reactivity bindings
riccardoperra e69b86d
feat(table): add abstract `batch` fn to reactivity system
riccardoperra 05c95dc
feat(table): refactor vue, svelte, lit, preact adapters to support na…
riccardoperra 5d55d04
ci: apply automated fixes
autofix-ci[bot] 08ee80a
fix(react-table): try to fix set state in render
riccardoperra 720541b
Merge remote-tracking branch 'origin/alpha' into feat/native-reactivity
riccardoperra f8a9b2b
Merge remote-tracking branch 'origin/alpha' into feat/native-reactivity
riccardoperra f0baf47
chore: add some internal docs in reactivity bindings
riccardoperra 0e7278b
Merge branch 'alpha' into feat/native-reactivity
KevinVandy 4984c5c
package upgrade sync
KevinVandy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { computed, signal, untracked } from '@angular/core' | ||
| import { toObservable } from '@angular/core/rxjs-interop' | ||
| import { batch } from '@tanstack/angular-store' | ||
| import type { Atom, Observer, ReadonlyAtom } from '@tanstack/angular-store' | ||
| import type { | ||
| TableAtomOptions, | ||
| TableReactivityBindings, | ||
| } from '@tanstack/table-core' | ||
| import type { Injector, Signal, WritableSignal } from '@angular/core' | ||
|
|
||
| function signalToReadonlyAtom<T>( | ||
| signal: Signal<T>, | ||
| injector: Injector, | ||
| ): ReadonlyAtom<T> { | ||
| return Object.assign(signal, { | ||
| get: () => signal(), | ||
| subscribe: (observer: Observer<T>) => { | ||
| return toObservable(computed(signal), { injector: injector }).subscribe( | ||
| observer, | ||
| ) | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| function signalToWritableAtom<T>( | ||
| signal: WritableSignal<T>, | ||
| injector: Injector, | ||
| ): Atom<T> { | ||
| return Object.assign(signal.asReadonly(), { | ||
| set: (updater: T | ((prevVal: T) => T)) => { | ||
| typeof updater === 'function' | ||
| ? signal.update(updater as (val: T) => T) | ||
| : signal.set(updater) | ||
| }, | ||
| get: () => signal(), | ||
| subscribe: (observer: Observer<T>) => { | ||
| return toObservable(computed(signal), { injector: injector }).subscribe( | ||
| observer, | ||
| ) | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| export function angularReactivity(injector: Injector): TableReactivityBindings { | ||
| return { | ||
| createReadonlyAtom: <T>(fn: () => T, options?: TableAtomOptions<T>) => { | ||
| const signal = computed(() => fn(), { | ||
| equal: options?.compare, | ||
| debugName: options?.debugName, | ||
| }) | ||
| return signalToReadonlyAtom(signal, injector) | ||
| }, | ||
| createWritableAtom: <T>( | ||
| value: T, | ||
| options?: TableAtomOptions<T>, | ||
| ): Atom<T> => { | ||
| const writableSignal = signal(value, { | ||
| equal: options?.compare, | ||
| debugName: options?.debugName, | ||
| }) | ||
| return signalToWritableAtom(writableSignal, injector) | ||
| }, | ||
| untrack: untracked, | ||
| batch: (fn) => fn(), | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address test flakiness before unskipping.
The TODO comment indicates this test "switches between 1 and 2 calls on every other run." Re-enabling a known flaky test may cause intermittent CI failures. Consider either resolving the underlying timing issue or adding a more robust synchronization mechanism before unskipping.
🤖 Prompt for AI Agents