* Set subscription status and emit events if changed
(newStatus: SubscriptionStatus)
| 267 | * Set subscription status and emit events if changed |
| 268 | */ |
| 269 | private setStatus(newStatus: SubscriptionStatus) { |
| 270 | if (this._status === newStatus) { |
| 271 | return // No change |
| 272 | } |
| 273 | |
| 274 | const previousStatus = this._status |
| 275 | this._status = newStatus |
| 276 | |
| 277 | // Emit status:change event |
| 278 | this.emitInner(`status:change`, { |
| 279 | type: `status:change`, |
| 280 | subscription: this, |
| 281 | previousStatus, |
| 282 | status: newStatus, |
| 283 | }) |
| 284 | |
| 285 | // Emit specific status event |
| 286 | const eventKey: `status:${SubscriptionStatus}` = `status:${newStatus}` |
| 287 | this.emitInner(eventKey, { |
| 288 | type: eventKey, |
| 289 | subscription: this, |
| 290 | previousStatus, |
| 291 | status: newStatus, |
| 292 | } as SubscriptionEvents[typeof eventKey]) |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Track a loadSubset promise and manage loading status |
no test coverage detected