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

feat: support StateValue for transition parameters #30

Open
2 tasks done
boneskull opened this issue Aug 13, 2024 · 0 comments
Open
2 tasks done

feat: support StateValue for transition parameters #30

boneskull opened this issue Aug 13, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@boneskull
Copy link
Owner

boneskull commented Aug 13, 2024

Bug Report Checklist

Overview

When using runUntilTransition(Actor, string, string), I should be able to use a StateValue instead of just a string. Per XState:

export interface StateValueMap {
  [key: string]: StateValue | undefined;
}

/**
 * The string or object representing the state value relative to the parent
 * state node.
 *
 * @remarks
 * - For a child atomic state node, this is a string, e.g., `"pending"`.
 * - For complex state nodes, this is an object, e.g., `{ success:
 *   "someChildState" }`.
 */
export type StateValue = string | StateValueMap;

So while StateValueFrom<Actor['logic']> can be used to handle the above, but it appears we'd need to "flatten" that type to allow them to be specified as a "keypath"; e.g., pending | success.someChildState.

And finally the leading id in the state keypath should be optional; right now it is required as that's what's stored as the keys of the private/internal idMap. Note that the keys of idMap are only string values.

@boneskull boneskull added the enhancement New feature or request label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant