From 69fe0237f15a4cc37270a41a5112d4e6b84a4321 Mon Sep 17 00:00:00 2001 From: Cristian Velasquez Ramos Date: Sun, 14 Jan 2024 20:19:38 -0500 Subject: [PATCH] reuse subscribable type --- packages/core/src/system.ts | 49 +++++++------------------------------ 1 file changed, 9 insertions(+), 40 deletions(-) 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,