October 2017
Intermediate to advanced
280 pages
6h 50m
English
Let's take a look at how we currently keep the to-do items in the TodoApp component:
class TodoApp {
todos: Todo[] = [...];
...
}
We use an array of Todo items. The JavaScript array is mutable, which means that if we pass it to a component that uses the OnPush strategy, it is not safe to skip the change detection in case we get the same input reference. For instance, we may have two components that use the same list of to-do items. Both components can modify the list since it is mutable. This will lead to an inconsistent state for any of the components in case their change detection is not performed. That's why we need to make sure that the list that holds the items is immutable. All we need to do in the ...
Read now
Unlock full access