1
- import { NgZone } from '@angular/core' ;
1
+ import { ɵmarkDirty as markDirty } from '@angular/core' ;
2
2
import { Predicate } from '../types/predicate' ;
3
3
4
4
/**
5
5
* TODO: This will not be needed in Angular 10
6
6
* when libraries are allowed to use Ivy renderer and markDirty becomes stable API
7
7
*/
8
- export function shouldCall < T > ( predicate : Predicate < T > ) : MethodDecorator {
8
+ /* export function shouldCall<T>(predicate: Predicate<T>): MethodDecorator {
9
9
return (_, key, desc: PropertyDescriptor) => {
10
10
const {value} = desc;
11
11
@@ -23,20 +23,20 @@ export function shouldCall<T>(predicate: Predicate<T>): MethodDecorator {
23
23
});
24
24
};
25
25
};
26
- }
26
+ } */
27
27
28
28
/**
29
29
* TODO: Use this in Angular 10
30
30
*/
31
- // export function shouldCall<T extends object>(predicate: Predicate<T>): MethodDecorator {
32
- // return (_: Object, _key: string | symbol, desc: PropertyDescriptor) => {
33
- // const {value} = desc;
34
- //
35
- // desc.value = function(this: T, ...args: any[]) {
36
- // if (predicate.apply(this, args)) {
37
- // value.apply(this, args);
38
- // markDirty(this);
39
- // }
40
- // };
41
- // };
42
- // }
31
+ export function shouldCall < T extends object > ( predicate : Predicate < T > ) : MethodDecorator {
32
+ return ( _ : Object , _key : string | symbol , desc : PropertyDescriptor ) => {
33
+ const { value} = desc ;
34
+
35
+ desc . value = function ( this : T , ...args : any [ ] ) {
36
+ if ( predicate . apply ( this , args ) ) {
37
+ value . apply ( this , args ) ;
38
+ markDirty ( this ) ;
39
+ }
40
+ } ;
41
+ } ;
42
+ }
0 commit comments