import { Props } from "./props" ; import processRegistry from "./processRegistry" ; import { IContext } from "./localContext" ; import { PID } from "./pid" ; import { Message } from "./messages" ; import { ISupervisor } from "./supervision" ; import { RestartStatistics } from "./restartStatistics" ; export function fromFunc ( fn ) { return fromProducer ( ( ) => new EmptyActor ( fn ) ) ; } export function fromProducer ( fn ) { return new Props ( ) . WithProducer ( fn ) ; } export function spawn ( props ) { var name = processRegistry . NextId ( ) ; return spawnNamed ( props , name ) ; } export function spawnPrefix ( props , prefix ) { var name = prefix + processRegistry . NextId ( ) ; return spawnNamed ( props , name ) ; } export function spawnNamed ( props , name ) { return props . Spawn ( name ) ; } class EmptyActor implements IActor { constructor ( private fn ) { } async Receive ( context ) { this . fn ( context ) ; } } export interface IActor { Receive ( context ) : Promise < void > ; } export const done = Promise . resolve ( ) ;