Currently diving into Angular 5, I've been exploring the Observable/Observer pattern to facilitate event sharing and data changes among subscribers.
Below is a snippet of the code in question:
...
@Injectable()
export class NidoService {
...
event$: Observable<StrutturaDto[]>;
private _observer: Observer<any>;
event_dettaglio$: Observable<Struttura>;
private _observer_dettaglio: Observer<any>;
constructor() {
this.event$ = new Observable(observer => this._observer = observer).share();
this.event_dettaglio$ = new Observable(observer => this._observer_dettaglio = observer).share();
}
...
}
Encountering challenges when trying to compile the application using ng build, errors appear on the lines within the constructor as follows:
ERROR in src/app/services/nido.service.ts(28,7): error TS2322: Type 'Observable<{}>' is not assignable to type 'Observable<StrutturaDto[]>'.
Type '{}' is not assignable to type 'StrutturaDto[]'.
Property 'includes' is missing in type '{}'.
src/app/services/nido.service.ts(29,7): error TS2322: Type 'Observable<{}>' is not assignable to type 'Observable<Struttura>'.
Type '{}' is not assignable to type 'Struttura'.
Property 'idStruttura' is missing in type '{}'.
In development mode, everything seems fine, but building becomes impossible without resolving these issues. How can I modify those specific lines of code?