Check out example codes for "clean up an angular subscription". It will help you in understanding the concepts better.

Code Example 1

@Component({...})export class AppComponent implements OnInit {    subscription: Subscription    ngOnInit () {        var observable = Rx.Observable.interval(1000);        this.subscription = observable.subscribe(x => console.log(x));    }}

Learn ReactJs, React Native from akashmittal.com