theater-client
Version:
TypeScript client library for Theater actor system TCP protocol
62 lines • 1.9 kB
TypeScript
/**
* Actor event stream implementation for subscribing to actor events
*/
import { EventEmitter } from 'node:events';
import type { TheaterConnection } from '../connection/TheaterConnection.js';
import type { TheaterClient } from './TheaterClient.js';
import type { TheaterId, SubscriptionId, ChainEvent } from '../types/protocol.js';
import type { ActorEventStream } from '../types/client.js';
/**
* Implementation of ActorEventStream for subscribing to actor events
* Manages a long-lived connection for receiving actor events
*/
export declare class ActorEventStreamImpl extends EventEmitter implements ActorEventStream {
readonly actorId: TheaterId;
readonly subscriptionId: SubscriptionId;
private connection;
private client;
private eventHandlers;
private closeHandlers;
private errorHandlers;
private _isActive;
private eventLoopRunning;
constructor(actorId: TheaterId, subscriptionId: SubscriptionId, connection: TheaterConnection, client: TheaterClient);
get isActive(): boolean;
/**
* Start the continuous event listening loop
*/
private startEventLoop;
/**
* Handle incoming responses from the connection
*/
private handleResponse;
/**
* Notify all event handlers of a new event
*/
private notifyEventHandlers;
/**
* Handle subscription close event
*/
private handleClose;
/**
* Handle error events
*/
private handleError;
/**
* Register an event handler
*/
onEvent(handler: (event: ChainEvent) => void): () => void;
/**
* Register a close handler
*/
onClose(handler: () => void): () => void;
/**
* Register an error handler
*/
onError(handler: (error: Error) => void): () => void;
/**
* Close the subscription
*/
close(): void;
}
//# sourceMappingURL=ActorEventStream.d.ts.map