@@ -66,6 +66,12 @@ export interface ActorSystem<T extends ActorSystemInfo>
66
66
* @internal
67
67
*/
68
68
_unregister : ( actorRef : AnyActorRef ) => void ;
69
+ /**
70
+ * @internal
71
+ */
72
+ _sendRegistrationEvent : (
73
+ event : RegistrationEvent < T [ 'actors' ] [ keyof T [ 'actors' ] ] >
74
+ ) => void ;
69
75
/**
70
76
* @internal
71
77
*/
@@ -179,13 +185,10 @@ export function createSystem<T extends ActorSystemInfo>(
179
185
children . set ( sessionId , actorRef ) ;
180
186
const systemId = reverseKeyedActors . get ( actorRef ) ;
181
187
if ( systemId !== undefined ) {
182
- const event = {
188
+ system . _sendRegistrationEvent ( {
183
189
type : `@xstate.actor.register` ,
184
190
systemId : systemId as string ,
185
191
actorRef : actorRef as T [ 'actors' ] [ keyof T [ 'actors' ] ]
186
- } as const ;
187
- registrationObservers . forEach ( ( listener ) => {
188
- listener . next ?.( event ) ;
189
192
} ) ;
190
193
}
191
194
return sessionId ;
@@ -197,14 +200,11 @@ export function createSystem<T extends ActorSystemInfo>(
197
200
if ( systemId !== undefined ) {
198
201
keyedActors . delete ( systemId ) ;
199
202
reverseKeyedActors . delete ( actorRef ) ;
200
- const event = {
203
+ system . _sendRegistrationEvent ( {
201
204
type : `@xstate.actor.unregister` ,
202
205
systemId : systemId as string ,
203
206
actorRef : actorRef as T [ 'actors' ] [ keyof T [ 'actors' ] ]
204
- } as const ;
205
- registrationObservers . forEach ( ( listener ) => {
206
- listener . next ?.( event ) ;
207
- } ) ;
207
+ } as const ) ;
208
208
}
209
209
} ,
210
210
get : ( systemId ) => {
@@ -268,6 +268,9 @@ export function createSystem<T extends ActorSystemInfo>(
268
268
( observer ) => observer . next ?.( resolvedInspectionEvent )
269
269
) ;
270
270
} ,
271
+ _sendRegistrationEvent : ( event ) => {
272
+ registrationObservers . forEach ( ( observer ) => observer . next ?.( event ) ) ;
273
+ } ,
271
274
_relay : ( source , target , event ) => {
272
275
system . _sendInspectionEvent ( {
273
276
type : '@xstate.event' ,
0 commit comments