-
-
Notifications
You must be signed in to change notification settings - Fork 96
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 Map doesn't work, possible regression #642
Comments
The first case has never been supported. Same for second case as they are both bound to function call result. So if the map never changed, It won't call the binding to update those text node. I think it's intentional, since we don't support observer function call result |
I had some code that was using this and I seem to remember it working before. Since map.get, for example, is not just a normal function, but a function whose result is explicitly tied to a map mutation, such as map.set, I'm thinking it would be possible, maybe reasonable, to observe these mutations. |
I dont know the full history so you could be right, then support for it was dropped. Maybe @jdanyow left those out for performance optimization ? |
Never was supported. Mr Davis here has a history of requesting method call observation. 😉 |
Haha okay, maybe I found a workaround for it like iterating over the map elements and then testing to see if it was equal to the one I actually wanted. However, I don't think this is an unreasonable thing to observe. These aren't arbitrary methods, and in fact Map.get is quite similar to Array[index] as we know Map.get will be updated by Map.set just like we know Array[index] will be updated by Array methods including splice. I think this Array use case--in an issue also opened by yours truly--was eventually added: #64 |
@jdanyow @bigopon I'm looking at the map-observation code here: https://github.com/aurelia/binding/blob/master/src/map-observation.js#L42 So basically, this works on a repeat but not on a Wouldn't there be a way to extend the get function to add it as a subscriber to the map's subscriber collection? This was brought up on Discourse here: https://discourse.aurelia.io/t/updating-a-map-doesnt-trigger-binding-updates/264/3 |
I'm submitting a bug report
1.5.0
Current behavior:
No observation of map.get
Expected/desired behavior:
Observe map.get
What is the expected behavior?
https://gist.run/?id=97468444c5aea6042dfbdd3ccf6c7b2c
What is the motivation / use case for changing the behavior?
Observe maps
The text was updated successfully, but these errors were encountered: