Skip to content

Instantly share code, notes, and snippets.

@Stuff90
Last active September 17, 2019 13:27
Show Gist options
  • Select an option

  • Save Stuff90/a805c60ab27279cdb6aed4477d5661ba to your computer and use it in GitHub Desktop.

Select an option

Save Stuff90/a805c60ab27279cdb6aed4477d5661ba to your computer and use it in GitHub Desktop.
import { Observable } from 'rxjs/Observable';
import { DataSource } from '@angular/cdk/collections';
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { MyAwesomeData } from './my/awesome/data.model.ts';
@Component({
selector: 'app-some',
templateUrl: './app-some.component.html',
styleUrls: ['./app-some.component.scss']
})
export class SomeComponent implements OnInit, OnDestroy {
@Input() source: DataSource<MyAwesomeData>;
data: Observable<MyAwesomeData[]>;
ngOnInit() {
this.data = this.source.connect();
}
ngOnDestroy() {
this.source.disconnect();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment