Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subscribe(datasource) {
this.data = [];
this.filteredData = [];
let observableDatasource = null;
// datasource can be an observable, an array of arrays or an array of objects
if (Array.isArray(datasource) && (Array.isArray(datasource[0]) || typeof datasource[0] === 'object')) {
observableDatasource = Observable.of(datasource);
} else if (Observable.isObservable(datasource)) {
// datasource is a Rxjs observable
observableDatasource = datasource;
}
if (observableDatasource) {
this.dataSubscription = observableDatasource.subscribe(this.push.bind(this));
}
}