Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to write proxy function over funciton?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading