Hacker News new | past | comments | ask | show | jobs | submit login

Computed properties has always been a possibility in Angular, you'd just create a getter[0] based on multiple different values, works like a charm. This new way is probably faster, but I've honestly never had any issues with the other approach.

[0] https://www.typescripttutorial.net/typescript-tutorial/types...




The problem I had with getters in a fairly complex application (WYSIWYG editor) was handling mouse events, in particular onMouseMove - change detection was triggered on every such event, and the application was very slow. EDIT: It was slow because there were many getters based on other getters etc and everything was recalculated on each event.


I don’t think a computed property would behave any better. It sounds like your event handling should have been decoupled from change detection and only applied changes when necessary. This would probably be a problem in any framework.


This is an issue with zone.js + getters, I changed the key components to OnPush change detection.


Will the getter result be cached? If not, it's not a computed property.


I’d expect that it’s not cached. But then I would go ahead and call that memoization.


The concept is actually slightly different. With memoization you store a map from inputs to outputs. A computed property doesn't necessarily do this, it just caches the result of the last computation.

The important part is that a computed property tracks its dependencies and is automatically re-calculated ONLY when necessary. If it behaves differently, it's not equivalent to the concept of a computed property in Vue.


According to what definition?


Isn't that just semantics? Whatever name you give the feature "lazily computed and cached values in the context of web frameworks", previously Angular didn't have them (built in) and now they do.


Angular did have it, it is called RxJS.


According to the "definition" on the Vue documentation page for computed properties: https://vuejs.org/guide/essentials/computed.html#computed-ca...


That describe what a computed properly is in the context of Vue.


Are you aware what comment tree you are in? This whole thing started because GP wrote this:

> For example, this update brings us computed properties, an essential feature for any complex performant web application that was made popular by Vue.js 10 years ago [1].

So obviously the relevant definition is "what the feature does in Vue". What is your issue here?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: