MCPcopy
hub / github.com/TanStack/ai / subscribe

Method subscribe

packages/ai-client/src/chat-client.ts:1093–1106  ·  view source on GitHub ↗

* Start the client subscription loop. * This controls the connection lifecycle independently from request lifecycle.

(options?: { restart?: boolean })

Source from the content-addressed store, hash-verified

1091 * This controls the connection lifecycle independently from request lifecycle.
1092 */
1093 subscribe(options?: { restart?: boolean }): void {
1094 const restart = options?.restart === true
1095 if (this.isSubscribed && !restart) {
1096 return
1097 }
1098
1099 if (this.isSubscribed && restart) {
1100 this.abortSubscriptionLoop()
1101 }
1102
1103 this.setIsSubscribed(true)
1104 this.setConnectionStatus('connecting')
1105 this.startSubscription()
1106 }
1107
1108 /**
1109 * Unsubscribe and fully tear down live behavior.

Callers 5

injectChatFunction · 0.95
useChatFunction · 0.95
ensureSubscriptionMethod · 0.95
updateOptionsMethod · 0.95
createChatFunction · 0.95

Calls 4

abortSubscriptionLoopMethod · 0.95
setIsSubscribedMethod · 0.95
setConnectionStatusMethod · 0.95
startSubscriptionMethod · 0.95

Tested by

no test coverage detected