Skip to content
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

Allow one time binding input #55581

Open
Harpush opened this issue Apr 29, 2024 · 1 comment
Open

Allow one time binding input #55581

Harpush opened this issue Apr 29, 2024 · 1 comment
Labels
area: core Issues related to the framework runtime core: inputs / outputs
Milestone

Comments

@Harpush
Copy link

Harpush commented Apr 29, 2024

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

We now have two options:

  1. Attribute - no change watching but no binding too. Limited to only compile time strings.
  2. Input - signal based and can change over time.

What's missing is the in between. A way to pass an input but without change watching.

The idea came from inputs I can't or don't want to handle when they change. Currently using ngOnChanges first change check I throw an error if it gets changed after first time.

Proposed solution

A way to declare on time input. Something like:
a = input.oneTime<string>() and will be just a string. If changed after first time will throw an error.
It will also make performance better (I think?) as no need for signal or tracking.

Alternatives considered

Check in ngOnChanges for first change and throw error. With signal inputs it's tougher as ngOnChanges is discouraged.

@pkozlowski-opensource
Copy link
Member

Related to #14033 where we would, probably, also need the binding side of it (the reasoning being that one-value inputs should only be bound with either a static value or a one-time binding).

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime core: inputs / outputs labels Apr 30, 2024
@ngbot ngbot bot added this to the needsTriage milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime core: inputs / outputs
Projects
None yet
Development

No branches or pull requests

2 participants