| 285 | return this |
| 286 | } |
| 287 | update(f: (value: A[K]) => A[K]): AtomRef<A[K]> { |
| 288 | if (Array.isArray(this.parent.value)) { |
| 289 | const newArray = this.parent.value.slice() |
| 290 | newArray[this._prop as number] = f(this.parent.value[this._prop]) |
| 291 | this.parent.set(newArray as A) |
| 292 | } else { |
| 293 | this.parent.set({ |
| 294 | ...this.parent.value, |
| 295 | [this._prop]: f(this.parent.value[this._prop]) |
| 296 | }) |
| 297 | } |
| 298 | return this |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | class CollectionImpl<A> extends ReadonlyRefImpl<Array<AtomRef<A>>> implements Collection<A> { |