Skip to content

Conversation

Hebilicious
Copy link

@Hebilicious Hebilicious commented Sep 25, 2024

fix #5091

I'm 100% sure this is not the best way to do this, but this works on my end ... So I will need to investigate this further. Will let this open as a draft for now.

@changeset-bot
Copy link

changeset-bot bot commented Sep 25, 2024

⚠️ No Changeset found

Latest commit: e7e5e44

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Hebilicious Hebilicious changed the title fix: triggerRef in the update selected function fix(vue): triggerRef in the update selected function Sep 25, 2024
@Hebilicious Hebilicious marked this pull request as draft September 25, 2024 08:06
@Andarist
Copy link
Collaborator

Please add a test case verifying the fixed behavior.

@Hebilicious
Copy link
Author

Hebilicious commented Sep 25, 2024

Please add a test case verifying the fixed behavior.

Hi @Andarist

Due to the tests failing, I went ahead and investigated in depth, and found out that the issue wasn't related to xstate, but to the way vue works with Map objects (realised that the issue was happening with Map only). So as far as I know this is not related to xstate. And doing something like useSelector(myRef, s => [...s.context.myMap.values()]) would properly update.
I will investigate more on the vue side and try to reproduce the issue without xstate.

On another note, I did some performance adjustements: I've noticed that useSelector is called in useActor, which is not necessary. Additionally it might be better to suggest using vue native computed to derive state, as it will not create an extra watcher and simply automatically update given that snapshot from useActor is a vue ref. Assuming a nested list scenario, useSelector could create a lot of watchers which is not necessary if the user just want to read the context (assuming this is the primary use of useSelector).

Should I update this PR with the performance adjustement and some suggested doc updates ?

@Andarist
Copy link
Collaborator

I'd prefer new dedicated PRs instead of repurposing this one

@Hebilicious
Copy link
Author

for reference #5382

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

Successfully merging this pull request may close these issues.

Bug: (vue) vue reactivity is sometimes not properly triggered

2 participants