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

transformResponse() cannot return reactive() object in development #787

Closed
matthew-white opened this issue May 9, 2023 · 1 comment
Closed
Assignees
Labels
infrastructure Changes to core libraries or setup requestData Changes to requestData resources

Comments

@matthew-white
Copy link
Member

When it receives a response from Backend, a requestData resource by default simply stores the response data. However, the resource can first transform the data by specifying a transformResponse() function. transformResponse() can be used to make the data fully or partly reactive. By default, the data is not reactive.

All that works well in production. However, we use Pinia in limited ways in development, and things don't always end up working. If transformResponse() returns a nonreactive object, then the Pinia store will store that. If transformResponse() returns a shallowReactive() object, then Pinia will correctly store that. However, if transformResponse() returns a fully reactive() object, then getting the data from the store returns a nonreactive object (!).

I'm not quite sure why that is. I suspect it has something to do with the fact that the initial state passed to the Pinia store is shallowReactive(), not reactive(). Just a guess, but it's possible that Pinia doesn't offer a lot of support for shallowReactive() objects.

Again, everything works as expected in production (without Pinia). This hasn't come up before in development because most data isn't reactive, and the data that is is usually shallowReactive(). However, I'm now making the entity resource fully reactive and have been running into issues. For now, I'll turn off Pinia in development, matching what happens in production.

@matthew-white matthew-white added the requestData Changes to requestData resources label May 9, 2023
matthew-white added a commit that referenced this issue May 9, 2023
@matthew-white matthew-white added the infrastructure Changes to core libraries or setup label Nov 19, 2024
@matthew-white matthew-white self-assigned this Nov 19, 2024
@github-project-automation github-project-automation bot moved this to 🕒 backlog in ODK Central Nov 19, 2024
@matthew-white matthew-white moved this from 🕒 backlog to ✏️ in progress in ODK Central Nov 19, 2024
@matthew-white
Copy link
Member Author

Closing now that #1050 has been merged.

@github-project-automation github-project-automation bot moved this from ✏️ in progress to ✅ done in ODK Central Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Changes to core libraries or setup requestData Changes to requestData resources
Projects
Status: ✅ done
Development

No branches or pull requests

1 participant