* Update service state and emit change event
(newState: Partial<TState>)
| 65 | * Update service state and emit change event |
| 66 | */ |
| 67 | protected setState(newState: Partial<TState>): void { |
| 68 | const previousState = this.currentState; |
| 69 | this.currentState = { ...this.currentState, ...newState }; |
| 70 | // Only log state updates if not in production to avoid circular reference issues |
| 71 | if (process.env.NODE_ENV !== "production") { |
| 72 | logger.debug(`${this.serviceName} state updated`); |
| 73 | } |
| 74 | this.emit("stateChanged", this.currentState, previousState); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Check if service is ready for use |