/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** * A repeater that destroys views when they are removed from a * {@link ViewContainerRef}. When new items are inserted into the container, * the repeater will always construct a new embedded view for each item. * * @template T The type for the embedded view's $implicit property. * @template R The type for the item in each IterableDiffer change record. * @template C The type for the context passed to each embedded view. */ export class _DisposeViewRepeaterStrategy { applyChanges(changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) { changes.forEachOperation((record, adjustedPreviousIndex, currentIndex) => { let view; let operation; if (record.previousIndex == null) { const insertContext = itemContextFactory(record, adjustedPreviousIndex, currentIndex); view = viewContainerRef.createEmbeddedView(insertContext.templateRef, insertContext.context, insertContext.index); operation = 1 /* _ViewRepeaterOperation.INSERTED */; } else if (currentIndex == null) { viewContainerRef.remove(adjustedPreviousIndex); operation = 3 /* _ViewRepeaterOperation.REMOVED */; } else { view = viewContainerRef.get(adjustedPreviousIndex); viewContainerRef.move(view, currentIndex); operation = 2 /* _ViewRepeaterOperation.MOVED */; } if (itemViewChanged) { itemViewChanged({ context: view?.context, operation, record, }); } }); } detach() { } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGlzcG9zZS12aWV3LXJlcGVhdGVyLXN0cmF0ZWd5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9jb2xsZWN0aW9ucy9kaXNwb3NlLXZpZXctcmVwZWF0ZXItc3RyYXRlZ3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBaUJIOzs7Ozs7OztHQVFHO0FBQ0gsTUFBTSxPQUFPLDRCQUE0QjtJQUd2QyxZQUFZLENBQ1YsT0FBMkIsRUFDM0IsZ0JBQWtDLEVBQ2xDLGtCQUE0RCxFQUM1RCxpQkFBdUQsRUFDdkQsZUFBZ0Q7UUF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hdGlvbi5NT1ZFRDtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChpdGVtVmlld0NoYW5nZWQpIHtcbiAgICAgICAgICBpdGVtVmlld0NoYW5nZWQoe1xuICAgICAgICAgICAgY29udGV4dDogdmlldz8uY29udGV4dCxcbiAgICAgICAgICAgIG9wZXJhdGlvbixcbiAgICAgICAgICAgIHJlY29yZCxcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgfSxcbiAgICApO1xuICB9XG5cbiAgZGV0YWNoKCkge31cbn1cbiJdfQ==