Actor.d.ts 1.5 KB

12345678910111213141516171819202122232425
  1. import { EventObject, Subscribable, InvokeDefinition, AnyEventObject, StateMachine, Spawnable, SCXML, ActorRef, BaseActorRef } from './types';
  2. export interface Actor<TContext = any, TEvent extends EventObject = AnyEventObject> extends Subscribable<TContext> {
  3. id: string;
  4. send: (event: TEvent) => any;
  5. stop?: () => any | undefined;
  6. toJSON: () => {
  7. id: string;
  8. };
  9. meta?: InvokeDefinition<TContext, TEvent>;
  10. state?: any;
  11. deferred?: boolean;
  12. }
  13. export declare function createNullActor(id: string): ActorRef<any>;
  14. /**
  15. * Creates a deferred actor that is able to be invoked given the provided
  16. * invocation information in its `.meta` value.
  17. *
  18. * @param invokeDefinition The meta information needed to invoke the actor.
  19. */
  20. export declare function createInvocableActor<TC, TE extends EventObject>(invokeDefinition: InvokeDefinition<TC, TE>, machine: StateMachine<TC, any, TE, any>, context: TC, _event: SCXML.Event<TE>): ActorRef<any>;
  21. export declare function createDeferredActor(entity: Spawnable, id: string, data?: any): ActorRef<any, undefined>;
  22. export declare function isActor(item: any): item is ActorRef<any>;
  23. export declare function isSpawnedActor(item: any): item is ActorRef<any>;
  24. export declare function toActorRef<TEvent extends EventObject, TEmitted = any, TActorRefLike extends BaseActorRef<TEvent> = BaseActorRef<TEvent>>(actorRefLike: TActorRefLike): ActorRef<TEvent, TEmitted> & Omit<TActorRefLike, keyof ActorRef<any, any>>;
  25. //# sourceMappingURL=Actor.d.ts.map