Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Propagate clock and logger from system #4822

Conversation

davidkpiano
Copy link
Member

@davidkpiano davidkpiano commented Apr 3, 2024

The clock and logger specified in the options object of createActor(logic, options) will now propagate to all actors created within the same actor system.

import { setup, log, createActor } from 'xstate';

const childMachine = setup({
  // ...
}).createMachine({
  // ...
  // Uses custom logger from root actor
  entry: log('something')
});

const parentMachine = setup({
  // ...
}).createMachine({
  // ...
  invoke: {
    src: childMachine
  }
});

const actor = createActor(parentMachine, {
  logger: (...args) => {
    // custom logger for args
  }
});

actor.start();

@davidkpiano davidkpiano linked an issue Apr 3, 2024 that may be closed by this pull request
Copy link

changeset-bot bot commented Apr 3, 2024

🦋 Changeset detected

Latest commit: 63446e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
xstate Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codesandbox-ci bot commented Apr 3, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@davidkpiano davidkpiano changed the title Add logger to spawned actors [core] Propagate clock and logger from system Apr 5, 2024
@davidkpiano davidkpiano marked this pull request as ready for review April 5, 2024 21:14
@davidkpiano davidkpiano merged commit f7f1fbb into main Apr 9, 2024
1 check passed
@davidkpiano davidkpiano deleted the davidkpiano/4634-bug-logger-not-propagated-to-child-machines-from-root branch April 9, 2024 14:36
@github-actions github-actions bot mentioned this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Logger not propagated to child machines from root
2 participants