* Safely update the collection status with validation * @private
(
newStatus: CollectionStatus,
allowReady: boolean = false,
)
| 91 | * @private |
| 92 | */ |
| 93 | public setStatus( |
| 94 | newStatus: CollectionStatus, |
| 95 | allowReady: boolean = false, |
| 96 | ): void { |
| 97 | if (newStatus === `ready` && !allowReady) { |
| 98 | // setStatus('ready') is an internal method that should not be called directly |
| 99 | // Instead, use markReady to transition to ready triggering the necessary events |
| 100 | // and side effects. |
| 101 | throw new CollectionStateError( |
| 102 | `You can't directly call "setStatus('ready'). You must use markReady instead.`, |
| 103 | ) |
| 104 | } |
| 105 | this.validateStatusTransition(this.status, newStatus) |
| 106 | const previousStatus = this.status |
| 107 | this.status = newStatus |
| 108 | |
| 109 | // Emit event |
| 110 | this.events.emitStatusChange(newStatus, previousStatus) |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Validates that the collection is in a usable state for data operations |
no test coverage detected