Skip to content
Discussion options

You must be logged in to vote

Great question - and yeah sorry about losing access to sender through the transitions; that's how it currently works in v5.

The "cleanest" v5 approach is exactly what you suspected: store the sender reference in context. It's not as messy as you might think - actor references are lightweight and designed to be passed around. There shouldn't be a memory leak concern (please file a bug if you see one; I'll also double-check).

const authServerMachine = createMachine({
  id: 'server',
  initial: 'waitingForCode',
  context: {
    user: {} as { id: string; token: string },
    replyTo: null as ActorRef<any, any> | null,
  },
  states: {
    waitingForCode: {
      on: {
        CODE: {
          

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jasonmacdonald-lgtm
Comment options

@davidkpiano
Comment options

Answer selected by jasonmacdonald-lgtm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants