MCPcopy Create free account
hub / github.com/TanStack/db / setStatus

Method setStatus

packages/db/src/collection/lifecycle.ts:93–111  ·  view source on GitHub ↗

* Safely update the collection status with validation * @private

(
    newStatus: CollectionStatus,
    allowReady: boolean = false,
  )

Source from the content-addressed store, hash-verified

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

Callers 2

markReadyMethod · 0.95
performCleanupMethod · 0.95

Calls 2

emitStatusChangeMethod · 0.80

Tested by

no test coverage detected