benmccallum
benmccallum

Reputation: 1378

VueJS list ordering based on async child-gathered data

I have an interesting situation as follows. I have:

Basically the component tree is:

Up until now I've been able to pass down the tree using props just the web url of the result item to the scoring components and keep the score service call and data local to each score component. This nicely separates all the logic.

Nonetheless, what I'd like to achieve now is:

I've been looking at Vuex, and it seems like it may be the best approach but before I dive all the way in I'd like to verify my thoughts and if people think it'd actually work.

Should I:

Is this the best way to do it? Any gotchas? Thanks!

Upvotes: 1

Views: 620

Answers (1)

reinerBa
reinerBa

Reputation: 1660

It's all as you suggested. But to add the scores to each result item you should use an array in the result item instead of using set. In my opinion using .push is the best way to ensure reactivity and clearity.

Comparing objects by refs works even when they are in vuex. I tested it here https://jsfiddle.net/posva/6w3ks04x/

Upvotes: 1

Related Questions