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
Observing getter property results in TypeError: context is not a function #252
Comments
With bindables, you just create a method on your class to get the change callbacks. In this case |
Example @customAttribute('some-widget')
export class SomeWidget {
@bindable readOnly = false;
readOnlyChanged(newValue, oldValue) {
//do stuff here...
}
} |
Of course, as soon as I posted this I figured something new out... the problem isn't with @bindable, so much as it is with the property on my view that I am binding to being a getter. Is that going to be supported in the future? I will also try your suggestion... I am modifying someone else's code and forgot about that feature. |
I do get the same error with the getter and using readOnlyChanged(). |
Getter? I don't understand what you mean by that. |
I need to see an example that is more representative of what you are actually doing. You can observe getters but you cannot use the |
Yep - no problem. My parent view model has this:
I am able to bind to this in other places in my view, but when I do it for my custom attribute, I get the above error. So, for instance, this works:
but this results in an error:
I see why you are saying it doesn't work - because @bindable is generating it's own getter and setter. Seems a little inconsistent though. |
FYI - I got it working in my case by not using the getter and binding to an expression:
But I was hoping the getter would clean up my template a bit. |
You should not be getting the error with the above code. Can you create a repro on the skeleton-navigation so I can see the error and track it down? |
Yep - I will try to do so later tonight or tomorrow. |
@EisenbergEffect Of course I have not been able to reproduce this off of the skeleton project. But, I did figure out that it if I don't use 'aurelia-computed' in my application, then I do not get the error. (I still can't reproduce it yet in the skeleton app even with 'aurelia-computed' added.) So, it is likely something else we are doing wrong in combination with a bug in 'aurelia-computed' of some sort. Thanks for the help - and sorry for creating an issue prematurely! I will create an issue for aurelia-computed if I can ever narrow it down any more. |
Hi The problem seems to be in the callSubscriber function, when there is a large amount of computed properties depending on the value of another view model property, thus resulting in deep nested calls. The last for loop in the function set Hope it can help identify the source of the problem.. EDIT: obviously one can simply add a EDIT 2: I can confirm that this bug is related to the |
I have a custom attribute class that has a @bindable property that I would like to watch for changes. I use the BindingEngine to create a PropertyObserver and use that to subscribe to the property in question. When the property changes, I get the following error:
Here are some code snippets... some code removed for conciseness:
The exact same code works without issue if remove the @bindable property and just create the property on 'this'. Obviously, I don't get the value of 'readOnly' that I am binding to in the parent in that case, however.
The text was updated successfully, but these errors were encountered: