* Sets the item on the given index in the list-value. \ * Dispatches a new copy of the value, without mutating the current-value. * * It only works if the Unit is not frozen, and the index is valid-numeric. * * @param index The index of the item. \ * A negative index is nor
(index: number, item: Item)
| 124 | * @category Custom ListUnit |
| 125 | */ |
| 126 | set(index: number, item: Item): void { |
| 127 | if (this.isFrozen || !isValidIndex(index)) { |
| 128 | return; |
| 129 | } |
| 130 | this.checkSerializabilityMaybe(item); |
| 131 | |
| 132 | const listShallowCopy = [...this.rawValue()]; |
| 133 | listShallowCopy[normalizeIndex(index, this.length)] = this.deepCopyMaybe(item); |
| 134 | this.updateValueAndCache(listShallowCopy); |
| 135 | |
| 136 | if (this.eventsSubject?.observers.length && !this.isMuted) { |
| 137 | this.eventsSubject.next(new EventListUnitSet(index, item)); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Inserts items to the list-{@link value}. \ |
nothing calls this directly
no test coverage detected