In this example, I have two cases of a service that exposes an observable, test$. One through a getter, the other as a public field.
Is there any practical difference?
I have seen numerous examples of declarative programming using the field way. Is using a getter not considered declarative?
component:
@Component()
export const TestComp {
private test$ = this.testService.test$;
constructor(private testService: TestService){}
}
Case 1: Service with field value:
@Injectable()
export const TestService {
public test$ = of('test');
}
Case 2: Service with property/getter:
@Injectable()
export const TestService {
private _test$ = of('test');
public get test$() {
return this._test$;
}
}