xstate-audition
    Preparing search index...

    Function patchActor

    • Utility to mutate an existing TActor allowing addition of an inspector and/or new logger.

      Inspectors are additive, so adding a new inspector is not destructive. Inspectors are applied across the entire system; there is no way to inspect only one actor.

      The logger needs to be replaced with a new function that calls the original logger and the new logger. If the ActorRef is a root actor (the one created via createActor()), the logger will be set at the system level; otherwise it will only be set for the particular Actor.

      Warning: If you use this function and plan using unpatchActor, modifying the ActorRef's logger via external means will result in the loss of those modifications.

      Type Parameters

      • TActor extends AnyActorRef

        The type of ActorRef to patch

      Parameters

      Returns TActor

      The original actor, but modified

      This function is called internally (with its own instrumentation, as appropriate) by xstate-audition on the root Actor, and for every spawned Actor. That said, it may be useful otherwise to have granular control (e.g., when paired with waitForSpawn()).

      const actor = createActor(someLogic);
      let childActor = await waitForSpawn(actor, 'childId');
      childActor = patchActor(childActor, {
      logger: console.log,
      inspector: console.dir,
      });