diff --git a/packages/core/src/system.ts b/packages/core/src/system.ts index cf49237dab..f0102a6396 100644 --- a/packages/core/src/system.ts +++ b/packages/core/src/system.ts @@ -6,7 +6,7 @@ import { AnyActorRef, Observer, Snapshot, - Subscription, + Subscribable, HomomorphicOmit, EventObject } from './types.ts'; @@ -47,7 +47,13 @@ function createScheduledEventId( return `${actorRef.sessionId}.${id}` as ScheduledEventId; } -export interface ActorSystem { +export interface ActorSystem + extends Subscribable< + RegistrationEvent< + T['actors'][keyof T['actors']], + keyof T['actors'] & string + > + > { /** * @internal */ @@ -65,43 +71,6 @@ export interface ActorSystem { */ _set: (key: K, actorRef: T['actors'][K]) => void; get: (key: K) => T['actors'][K] | undefined; - subscribe: { - ( - observer: Observer< - RegistrationEvent< - T['actors'][keyof T['actors']], - keyof T['actors'] & string - > - > - ): Subscription; - ( - nextListener?: ( - event: RegistrationEvent< - T['actors'][keyof T['actors']], - keyof T['actors'] & string - > - ) => void, - errorListener?: (error: any) => void, - completeListener?: () => void - ): Subscription; - ( - nextListenerOrObserver?: - | (( - event: RegistrationEvent< - T['actors'][keyof T['actors']], - keyof T['actors'] & string - > - ) => void) - | Observer< - RegistrationEvent< - T['actors'][keyof T['actors']], - keyof T['actors'] & string - > - >, - errorListener?: (error: any) => void, - completeListener?: () => void - ): Subscription; - }; inspect: (observer: Observer) => void; /** * @internal @@ -242,7 +211,7 @@ export function createSystem( return keyedActors.get(systemId) as T['actors'][any]; }, subscribe: ( - nextListenerOrObserver?: + nextListenerOrObserver: | ((event: RegistrationEvent) => void) | Observer>, errorListener?: (error: any) => void,