(key: K)
| 166 | } |
| 167 | |
| 168 | delete(key: K): boolean { |
| 169 | checkIfStateModificationsAreAllowed(this.keysAtom_) |
| 170 | if (hasInterceptors(this)) { |
| 171 | const change = interceptChange<IMapWillChange<K, V>>(this, { |
| 172 | type: DELETE, |
| 173 | object: this, |
| 174 | name: key |
| 175 | }) |
| 176 | if (!change) { |
| 177 | return false |
| 178 | } |
| 179 | } |
| 180 | if (this.has_(key)) { |
| 181 | const notifySpy = isSpyEnabled() |
| 182 | const notify = hasListeners(this) |
| 183 | const change: IMapDidChange<K, V> | null = |
| 184 | notify || notifySpy |
| 185 | ? { |
| 186 | observableKind: "map", |
| 187 | debugObjectName: this.name_, |
| 188 | type: DELETE, |
| 189 | object: this, |
| 190 | oldValue: (<any>this.data_.get(key)).value_, |
| 191 | name: key |
| 192 | } |
| 193 | : null |
| 194 | |
| 195 | if (__DEV__ && notifySpy) { |
| 196 | spyReportStart(change! as PureSpyEvent) |
| 197 | } // TODO fix type |
| 198 | transaction(() => { |
| 199 | this.keysAtom_.reportChanged() |
| 200 | this.hasMap_.get(key)?.setNewValue_(false) |
| 201 | const observable = this.data_.get(key)! |
| 202 | observable.setNewValue_(undefined as any) |
| 203 | this.data_.delete(key) |
| 204 | }) |
| 205 | if (notify) { |
| 206 | notifyListeners(this, change) |
| 207 | } |
| 208 | if (__DEV__ && notifySpy) { |
| 209 | spyReportEnd() |
| 210 | } |
| 211 | return true |
| 212 | } |
| 213 | return false |
| 214 | } |
| 215 | |
| 216 | private updateValue_(key: K, newValue: V | undefined) { |
| 217 | const observable = this.data_.get(key)! |
no test coverage detected