Skip to content

Support input signals in Angular adapter#291

Open
benjavicente wants to merge 5 commits intoTanStack:mainfrom
benjavicente:angular-signal-store
Open

Support input signals in Angular adapter#291
benjavicente wants to merge 5 commits intoTanStack:mainfrom
benjavicente:angular-signal-store

Conversation

@benjavicente
Copy link

@benjavicente benjavicente commented Mar 12, 2026

🎯 Changes

  • Adds support to input signals by allowing the first argument to be a function that returns the store
  • Correctly supports selectors with input signals by running the selector only in effects and linkedSignal.
  • Migrates angular tests to use testing library, like the other adapters

A full write out can be found here.

The main idea is that in Angular we can't call input signals on component initialization, so this fails:

export function injectRelativeTimestamp(timestamp: Signal<number>) {
  // Throws NG0952/NG0950: no model/input available yet
  const relativeTimestamp = new RelativeTime(timestamp());
}

By allowing a function/signal, we can allow consumers to lazy initialize the store, demonstrated by a couple of tests where createStableSignal (computed(() => untracked(fn))) is used. A previous PR #285 added that helper in the library, but since in React we are using useState or useRef without a helper to do the same idea (keeping a stable reference to the store), this PR does not provide a similar helper. Consumers are expected to keep the store getter function/signal stable.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@changeset-bot
Copy link

changeset-bot bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: 38ccc0b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/angular-store Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benjavicente benjavicente mentioned this pull request Mar 12, 2026
4 tasks
@KevinVandy KevinVandy requested a review from crutchcorn March 12, 2026 18:56
@nx-cloud
Copy link

nx-cloud bot commented Mar 12, 2026

View your CI Pipeline Execution ↗ for commit 38ccc0b


☁️ Nx Cloud last updated this comment at 2026-03-12 18:57:06 UTC

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