import { Component , OnInit , ChangeDetectionStrategy , ChangeDetectorRef , OnDestroy } from '@angular/core' ; import { NgForm } from '@angular/forms' ; import { Subject } from 'rxjs/Subject' ; export abstract class AppCommonAbstract implements OnDestroy { protected onDestroy$ : Subject < undefined > = new Subject ( ) ; protected changeDetectorRef : ChangeDetectorRef ; ngOnDestroy ( ) { this . onDestroy$ . next ( ) ; } protected onActionFinished < T > ( success , obj , setter , form ) { if ( success ) { if ( form ) { setter ( < any > { } ) ; form . reset ( ) ; } } else { setter ( { ... < any > obj , working : undefined } ) ; } if ( this . changeDetectorRef ) { this . changeDetectorRef . markForCheck ( ) ; } } trackMember ( index , { member } ) { return member || undefined ; } trackGratitude ( index ) { return `${ index }` || undefined ; } trackPoll ( index , poll ) { return poll && poll . address ; } }