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

Docs: Docs do not list all possible machine options keys #280

Open
MichalBryxi opened this issue Mar 22, 2022 · 4 comments
Open

Docs: Docs do not list all possible machine options keys #280

MichalBryxi opened this issue Mar 22, 2022 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@MichalBryxi
Copy link

Description

Looking at the docs of MachineOptions and it mentions only actions.

But from the Configuring services part of the guides

const userMachine = createMachine(
  {
      // ...
  },
  {
  services: {
    getUser: (context, event) => fetchUser(context.user.id)
  }
);

and Serialising guards

const searchMachine = createMachine(
  {
    // ...
  },
  {
    guards: {
      searchValid: (context, event) => {
        return context.canSearch && event.query && event.query.length > 0;
      }
    }
  }
);

it seems to me that the MachineOptions object can also have services and guards keys? So it should be mentioned in the guides.

Expected result

### Machine options

- `actions?` (object) - a lookup object for your string actions.
- `guards?` (object) - a lookup object for your string guards.
- `services?` (object) - a lookup object for your string services.

Actual result

Confusion? :)

Reproduction

N/A

Additional context

No response

@Andarist
Copy link
Member

Looking at the docs of MachineOptions and it mentions only actions.

This is a documentation of @xstate/fsm - it's a much simpler package and it only supports "configurable" actions at the moment.

@MichalBryxi
Copy link
Author

What would be a good place to look at all the possible keys for options object of createMachine(_, options) then?

@Andarist
Copy link
Member

Andarist commented Mar 22, 2022

I've tried to find one... and I couldn't (I could have missed it, but still...). The docs are currently introducing each concept separately and I didn't find a good "common" API reference in the docs for this. It's definitely something that we should improve.

The allowed keys there are actions, delays, guards and services.

@mattpocock
Copy link

@MichalBryxi Our plan for our new, revamped docs is to have a central API reference for this.

@mattpocock mattpocock added documentation Improvements or additions to documentation and removed bug Something isn't working labels Apr 6, 2022
@mattpocock mattpocock changed the title Bug: Machine options does not list all possible keys Docs: Docs do not list all possible machine options keys Apr 6, 2022
@mattpocock mattpocock self-assigned this Apr 6, 2022
NullVoxPopuli referenced this issue in NullVoxPopuli/ember-statechart-component Jul 3, 2022
Resolves: #268

There is a bit of a nomenclature mismatch in XState's docs and that is
reported here: https://github.com/statelyai/xstate/issues/3165
@davidkpiano davidkpiano transferred this issue from statelyai/xstate Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants