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

How to work with "state"? #522

Open
MichalBryxi opened this issue Dec 22, 2024 · 2 comments
Open

How to work with "state"? #522

MichalBryxi opened this issue Dec 22, 2024 · 2 comments

Comments

@MichalBryxi
Copy link
Contributor

MichalBryxi commented Dec 22, 2024

Hi,

I can see that for xstate matches there is a shorthand in ember-statechart-component:

<Toggle as |toggle|>
  (toggle.matches 'inactive')
</Toggle>

From the official xstate documentation it seems like it should also work in this way:

<!-- This does not work -->
<Toggle as |toggle|>
  (toggle.snapshot.matches 'inactive')
</Toggle>

But this does not work with:

Uncaught TypeError: Cannot read properties of undefined (reading 'value')

And respective this(?) is there set to undefined:

Screenshot 2024-12-22 at 17 33 54
(screenshot tests step1, but it's supposed to be inactive in the example above)

I came to this conclusion from an ability to access context on snapshot which works for me:

<Toggle as |toggle|>
  {{toggle.snapshot.context.isActive}}
</Toggle>

I do not necessarily care about how do I call state.matches as there is a way, but I wanted to access state.can and possibly other functions, but it does not work for me.

@NullVoxPopuli
Copy link
Owner

NullVoxPopuli commented Dec 22, 2024

aye, that's a bug with glimmer-vm, which (when fixed) will also unlock: emberjs/rfcs#1045

@NullVoxPopuli
Copy link
Owner

tracking issue: glimmerjs/glimmer-vm#1652

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

No branches or pull requests

2 participants