You can imagine that, if we have to traverse this tree to figure out all the state changes, this could take some time. Real-world applications are way bigger than this 107 components or so. They have thousands of components at runtime.
Angular was thinking what can we do to optimise the change detection on the reactivity system? We looked at expanding our compiler so that we can have static dependency tracking, and we decided that this is not the right way to go because it introduces some magic that might introduce challenges when debugging. We also explored signals. We joined the signals club, together with Vue, Solid, Svelte, and others. Inside signals, you just wrap your local component state inside of a signal. From there, you can read it inside of your templates, and this is enough to notify the framework, to let the framework know where exactly this state is being used, so that when you update the state, the framework can go there and perform change detection, let's say, in only this particular part of your component.
When you look at the larger component tree, and, let's say, we update the item.quantity and set it to one with a signal, we're going to go only to the components that have read the signal. In this case, let's say these two components, and the rest, we don't have to traverse, so this significantly improves the performance at runtime.
Signals became popular not only in the external community but also inside of Google. In Google, we have two frameworks for development of web applications that are in general availability. We have Angular and WIS. Angular has been more focused on enterprise-like experiences, and WIS on consumer clients. Let's say Google search is built with WIS, Google Photos, Google Drive, and more. In the external terminology of external frameworks, you can think about WIS being more similar to Eleventy or quick. In fact, WIS invented the concept of reasonability ten years ago. Originally, these two frameworks were occupying very different segments, but over time, we noticed how these requirements for the applications that we were building with Angular and WIS, they started to blend. People building applications with Angular wanted more of the Angular features. People using WIS wanted some of the developer experience features of Angular. We started collaborating together closely.
It was my responsibility to figure out what code we can share. I was hanging out in Google chat in the WIS channel, and I saw something like this. I definitely didn't manufacture the screenshot yesterday. WIS was working with YouTube to rewrite their whole user interface and move it from a legacy virtual DOM-based implementation to WIS, and they were exploring signals for fine-grain reactivity. Angular, on the other side, we were designing the Angular signals implementation at that point, so we decided to team up and build a solution together. YouTube adopted Angular signals through WIS, and it is currently handling 100 per cent of their YouTube mobile web traffic. They noticed some improvements. For instance, on living room, this is smart TVs, they saw about 35 per cent better input latency on low-end TVs, and when swiping shorts on YouTube mobile web, they noticed 60 frames per second swiping compared to the legacy virtual DOM implementation that was providing 25 frames per second. Seeing that these signals actually work, and they work across Angular and WIS, and we're able to share the exact same signals implementation, we reached out to standardisation bodies and they both representative of other frameworks who have been using signals as well.
Comments