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

[state] bind-for entity components don't update when non-key values change #244

Open
dsinni opened this issue Oct 3, 2019 · 3 comments
Open

Comments

@dsinni
Copy link
Contributor

dsinni commented Oct 3, 2019

I'm not sure if this is related to #243, as I've been forced to use the interpolation method for updating values (e.g., text="value: {{username}};"), due to bind-item not working as expected.

The issue is that I can't seem to get the bound entity components to update if the key does not change in the object.

As am example, I'd like to be able to update username in the following object, while using clientId as the key, since it is unique.

initialState: {
  users: [
    {
      clientId: '2ttwejglkjetot2asg',
      username: 'Bob'
    }
  ]
}

I've come up with a hacky workaround by using a separate id which is assigned a value with Date.now() appended, but then I need to remove and replace the user in order to get any updates, which also disturbs the display order.

To clarify, I can update the value in state, but changes are not reflected in the bound components.

I've tried using state.users.__dirty = true; to no avail.

Any guidance would be awesome.

Thanks for all you do.

@dsinni
Copy link
Contributor Author

dsinni commented Oct 10, 2019

This is happening in version 6.8.0, but haven't checked against all other versions yet.

@marlon360
Copy link
Contributor

@dsinni For me this works by using bind-item with item as the for value and setting state.users.__dirty = true;.

A-Frame: 0.9.2
frame-state-component: 6.8.0

Here is a working fiddle: https://jsfiddle.net/marlon360/3Lzmc65u/

@ngokevin
Copy link
Collaborator

thanks i tried updating the readme

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

No branches or pull requests

3 participants