Recently, I've been utilizing signals to replace certain properties in my components that would typically require computed logic or be reactive to the effect hook. It got me thinking - should I be replacing all of my properties with signals, even if they never change?
For instance, consider this component with a property called items, which is simply an array of objects used in the template to populate a dropdown. Is there any advantage to wrapping it in a signal instead of just keeping it as a regular property, especially if the property remains constant and is only set during initialization:
@Component({
selector: 'mobile-app-icons',
standalone: true,
templateUrl: './mobile-app-icons.component.html',
styleUrl: './mobile-app-icons.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
],
})
export class MobileAppIconsComponent {
// Would turning this into a signal have any benefits
iconTypes = [
{
title: 'App icon',
key: 'APP_ICON',
description: 'AppIconExplanation',
},
{
title: 'Splash screen icon',
key: 'SPLASH_ICON',
description: 'SplashIconExplanation',
},
];
}
On the surface, it seems like making this change wouldn't make much difference. However, I'm curious if there are any advantages in terms of change detection, or if I can simply keep these "simple" properties as they currently are.