breeze-client icon indicating copy to clipboard operation
breeze-client copied to clipboard

how to access methods from initializer?

Open ganySA opened this issue 5 years ago • 1 comments

I am registering a custom constructor as per the below: metadataStore.registerEntityTypeCtor('Client', Client, 'initializer');

How can i access this 'this' from the initalizer? I am trying to execute a method on propertyChanges.

    initializer(entity: Client) { 
    entity.entityAspect.propertyChanged.subscribe((changes)=>{
            this.refreshAdditionalProperties();
        }
    }

refreshAdditionalProperties()
{
Do something cool.
}

ganySA avatar Jun 24 '20 15:06 ganySA

What are you expecting this to be? The initializer is just a function. It gets the entity passed as the argument, so you can call any method on it, but as far as referring to anything else outside the initializer function goes, you gonna have to use a closure to capture whatever you need, or bind this using bind to what you need it to be.

marcelgood avatar Jun 24 '20 16:06 marcelgood