liveBook · Manning

IterableChanges

As explained in Pro Angular 16

IterableChanges is an Angular API object containing the records and operations needed to process changes detected in an iterable collection.

IterableChanges is the result of comparing an iterable with an Angular IterableDiffer. It contains detected changes, or the diff returns null when none are found, allowing a directive to skip unnecessary work. section 15.3.4

Table 15.4. The IterableChanges methods and properties
Name
Description
forEachItem(func)
This method invokes the specified function for each object in the collection.
forEachPreviousItem(func)
This method invokes the specified function for each object in the previous version of the collection.
forEachAddedItem(func)
This method invokes the specified function for each new object in the collection.
forEachMovedItem(func)
This method invokes the specified function for each object whose position has changed.
forEachRemovedItem(func)
This method invokes the specified function for each object that was removed from the collection.
forEachIdentityChange(func)
This method invokes the specified function for each object whose identity has changed.

Review the callbacks for processing items, additions, removals, moves, and identity changes. section 15.3.4

Callbacks receive an IterableChangeRecord describing an item, its current and previous indices, and—when trackBy is used—its identity value. A structural directive can use added-item records to create views for new product rows. section 15.3.4

How Pro Angular 16 covers it

How deep it goes
Lists six change-processing callbacks and records’ item, identity, and index fields.
Examples
Demonstrates creating views for added product rows and removing items from an iterable.
What you can do after
Apply it via Angular’s iterable differ to process additions and avoid rebuilding unchanged views.
How it connects
Connects IterableDiffer results to IterableChangeRecord fields and ngDoCheck processing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.