vuejs/vue-vapor

`createSelector`

LittleSound opened this issue · 5 comments

Discuss whether createSelector is needed to optimize performance.

Using functions like createSelector can reduce the time complexity of the select row item in the benchmark from O(n) to O(1).

Use createSelector in other frameworks

Here is some information about createSelector in other frameworks:

Use v-memo in Vue

It is important to note when using v-memo in Vue. We can achieve a similar effect:

<div v-for="item in list" :key="item.id" v-memo="[item.label, item.id === selected]">
  <p>{{ item.id }}: {{ item.label }} - selected: {{ item.id === selected }}</p>
  <p>...more child nodes</p>
</div>

Since v-memo is a more general API, the user experience will be somewhat different because you need to specify content other than id, such as item.label.

So what are your thoughts on this? Feel free to discuss.

CSS has already defined Selector, perhaps we need a more unique name?

CSS has already defined Selector, perhaps we need a more unique name?

Do you have any suggested names?

Being able to reduce time complexity from O(n) to O(1) is truly a great feat, wow. Would this be available to the users, or will it be used as an internal API?

sxzz commented

Like Solid.js, I believe createSelector should be public API and used for performance-sensitive cases.

sxzz commented

Done via #279