Just starting with Angular and attempting to activate the error callback during a subscribe function. I'm making changes to a table object and looking to display a toast message when a certain condition is met. This should occur either on error or completion.
// editCollection.component.ts
handleMoveRowsDown() {
this.collectionsStore.moveRowsDown(this.selectedRows).subscribe(
(collection) => {
this.table.sorts = [];
this.rowsSorted = true;
this.collection = collection;
this.table.rows = this.collection.rows;
},
(error) => {
console.error(error);
this.toastr.error("You've hit bottom!"); // show toast if "trigger" is true
this.selectedRows = [];
}
);
}
// collections.store.ts
moveRowsDown(selectedRows: DtRow[]): Observable<DtCollection> {
let trigger = false;
// manipulate table...
if (trigger) {
throw new Error(); // currently not effective
} else {
this.setCurrentCollection(tempCollection as DtCollection);
// how can I include trigger when returning asObservable?
return this._currentCollection.asObservable();
}
}