import { NgZone } from '@angular/core' ; import { Predicate } from '../types/predicate' ; /**
 * TODO: This will not be needed when markDirty becomes stable API
 */ export function shouldCall < T > ( predicate ) { return ( _ , key , desc ) => { const { value } = desc ; desc . value = function ( this , ... args ) { const zone = arguments [ 0 ] ; if ( zone instanceof NgZone ) { Object . defineProperty ( this , key , { value ( this , ... args ) { if ( predicate . apply ( this , args ) ) { zone . run ( ( ) => { value . apply ( this , args ) ; } ) ; } } , } ) ; } else if ( predicate . apply ( this , args ) ) { value . apply ( this , args ) ; } } ; } ; } /**
 * TODO: Use this after markDirty becomes public API
 */