Angular 17.1 was released according to plan. Signal Inputs are its main feature.
As the name says, components get their input value as a Signal. Instead of the decorator @Input, we use a function called input. We can now react to changes in the form of computed, effect or just get the value directly from the Signal.
Three flavors are available:
- input with a default value resolves to a Signal of one particular type.
- input without a default value requires a generic type. The result type is a union type containing undefined.
- input.required expects a generic type as well but comes without a union type of undefined. input.required, which could throw a runtime error if you access the value of the signal before the initialization of the component. That could be within the constructor.
Transformation functions for type mapping and parameter binding from the router are also possible.
For testing, the web test runner is available in an experimental mode. It will replace Karma, which runs Jasmine tests inside of the browser. There are no plans to replace Jasmine.
To use the Web Test Runner:
- install the dependency via
npm install @web/test-runner –save-dev
- Replace the builder in the angular.json, path "architect.test.builder" from "@angular-devkit/build-angular:karma" to "@angular-devkit/build-angular:web-test-runner".
- Run "ng test"
More information in the commit's description: "https://github.com/angular/angular-cli/commit/68dae539adfa12d6088f96ac5c9f224d9bb52e17"
There was some speculation about support for zoneless applications. We can disable zone.js and use a new scheduler to trigger the CD in markForCheck (which runs in the async pipe, handled DOM Events, immutable input property changes, or Signal changes).
To activate the new scheduler, add ɵprovideZonelessChangeDetection() to the providers property of the bootstrapApplication call.
At the moment, the new scheduler is an internal feature. Only use it if you want to live on the bleeding edge.
ngUpdate will not migrate to Signal Inputs. There is, though, a community migrator from Chau Tran:
Top comments (1)
Unfortunately @angular/fire does not work without ZoneJs, making it a showstopper for zoneless apps.