I have a class (interface) in my angular 4 app which has a lot of fields.
Note that the instance of this class/interface is immutable (i.e. the members will NEVER be changed).
E.g.
public interface IHaveALotOfFields {
field1: string;
//...
field500: string;
}
This interface is provided via a (singleton / application level provided) service which exposes the class as a member. E.g.
@Injectable()
public class MyService {
public translations: ITranslationsProvider;
}
The service is injected into a lot of components (almost all components) and often used in their corresponding template and often also in the ts-part of the component. E.g.
@Component({
template: `Value: {{service.field500}}`
})
export class MyComponent {
public constructor(public service: MyService) {
}
private doSomething(): string {
return this.service.field1;
}
}
Now my questions:
- Will a big class (with a lot of fields) make angular slow because of the change detection?
- Is there any way to mark a class as "Ignore me on change detection"? (something similar to
ChangeDetectionStrategy.OnPush, but instead of specifying this for each component, can be declared on the class itself or on the member of the service)
Please note that I don't want to change the change-detection strategy of all my components to OnPush.