There is a class with some several methods. One of them:
drawGeojson(layerid: string, geojsonObject) {
this.ngZone.run(() => {}
}
How to refactor the code – so that, on request, you can execute the method body with a wrapper
this.ngZone.run(() => {}
and without it?
I need something this:
The default call: drawGeojson()
The proxy call Wrapper.drawGeojson();
>Solution :
If you want conditionally execute
this.ngZone.run(() => {})
You can add an additional parameter to your method and depend on whether it execute or not.
wrapperZone(method: Function, execute: boolean) {
execute ? this.ngZone.run(() => {
method()
}) : method()
}
wrapperZone(this.drawGeojson.bind(this), true)