Skip to content

Instantly share code, notes, and snippets.

@NeuralGlue
Created December 12, 2019 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeuralGlue/8f7c0c166da1d5984efafe305a7b2913 to your computer and use it in GitHub Desktop.
Save NeuralGlue/8f7c0c166da1d5984efafe305a7b2913 to your computer and use it in GitHub Desktop.
export class MyObjectDatasourceService implements DataSource<MyObject> {
private myObjectSubject = new BehaviorSubject<MyObject[]>([]);
constructor(private myObjectService: MyObjectService){}
connect(collectionViewer: CollectionViewer): Observable<MyObject[]> {
return this.myObjectSubject.asObservable();
}
disconnect(collectionViewer: CollectionViewer): void {
this.myObjectSubject.complete();
}
loadVentures() {
this.myObjectService.fetchRemoteObjects()
.pipe(
catchError(() => of([]))
)
.subscribe ( myObjects => {
this.myobjectSubject.next(myObjects);
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment