Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to access methods from initializer? #33

Open
ganySA opened this issue Jun 24, 2020 · 1 comment
Open

how to access methods from initializer? #33

ganySA opened this issue Jun 24, 2020 · 1 comment

Comments

@ganySA
Copy link

ganySA commented Jun 24, 2020

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.
}

@marcelgood
Copy link

marcelgood commented Jun 24, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants