Skip to content

Xstate@v5 & context argument for getService() in fromPromise() #521

Description

@MichalBryxi

In xstate@v4 I could use:

  services: {
    fetchSearchResults: (context) => {
      getService(context, 'some-service').foo();
    }
  }

In xstate@v5 I'm trying similar (using the fromPormise):

  actors: { // in v5 `services` was renamed to `actors`
    fetchSearchResults: fromPromise(async (context) => {
      getService(context, 'some-service').foo(); // This will throw
    }),
  }

But the code will trow with:

Assertion Failed: Expected passed context to be aware of the container (owner)

I tried to manually inspect the provided object to see if I spot Symbol(OWNER): ApplicationInstance, but no luck.

I can, however, pass the entire context down as input and then use that. But that's a biiiit weird. Is there a nicer way to be able to use ember-statechart-component getService() inside fromPromise() callback?

invoke: {
  input: ({ context }) => {
    return context;
  },
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions