With angular if i have smart and dump components, if i have lets say an array in a smart component i need to make an observable out of it to make make the dump component read the input with an async pipe so that if i change the value of the array the detect change works and updated the dumb component. if i use just the array .
pieces = new ReplaySubject<{ item: Piece, index: number }[]>(1);
selectedPieces = new ReplaySubject<{ item: Piece, index: number }[]>(1);
piecesArray: { item: Piece, index: number }[];
selectedPiecesArray: { item: Piece, index: number }[] = [];
removePieces(pieces: { item: Piece, index: number }[]) {
this.piecesArray = this.piecesArray.concat(...pieces);
this.selectedPiecesArray = this.selectedPiecesArray.filter(p => pieces.indexOf(p) === -1);
this.pieces.next(this.piecesArray.sort((a, b) => a.index - b.index));
this.selectedPieces.next(this.selectedPiecesArray);
}
what is the right way to handle this. should i use just observable and subscribe to it every time i need to operate on the value ?