Underlying StreamApi returned by useStream.
@Injectable() wrapper around useStream. Extend this class
with your own service when you want a DI-scoped, shareable
StreamApi:
@Injectable({ providedIn: "root" })
export class ChatStream extends StreamService<ChatState> {
constructor() {
super({
transport: new HttpAgentServerAdapter({ apiUrl: "/api/graph" }),
assistantId: "chat",
});
}
}
The service exposes the same StreamApi surface as
injectStream() — read data via signals (service.messages(),
service.isLoading()) and use the imperative methods
(service.submit(...), service.stop()).
Must be instantiated inside an Angular injection context. Its DestroyRef owns the controller lifetime, so scoping the service to a component tears down the stream when the component is destroyed.