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

createSelector #277

Closed
LittleSound opened this issue Sep 19, 2024 · 5 comments
Closed

createSelector #277

LittleSound opened this issue Sep 19, 2024 · 5 comments
Assignees

Comments

@LittleSound
Copy link
Member

LittleSound commented Sep 19, 2024

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.

@typed-sigterm
Copy link

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

@LittleSound
Copy link
Member Author

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

Do you have any suggested names?

@icarusgk
Copy link

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
Copy link
Member

sxzz commented Sep 22, 2024

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

@sxzz
Copy link
Member

sxzz commented Sep 22, 2024

Done via #279

@sxzz sxzz closed this as completed Sep 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants