Skip to content

When to use createMemo? And when is it more overhead than it saves? #1932

Answered by atk
mb21 asked this question in Q&A
Discussion options

You must be logged in to vote

In react, you would use memos not to compute results with the same parameters twice, this is a non-issue in solid anyways, because signals already have an equality check, so they wouldn't trigger computations if updated with the same value. If only for that, you can use plain functions.

The same also applies to solid if a value from a complex computation is used multiple times. However, it is even more useful if you have signals with frequent changes but only need to call the subscribers on certain changes, because then you can use createMemo as a reactivity filter to improve performance pretty effectively. For example if you have a volume meter for an audio signal, but only show 4 bars t…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mb21
Comment options

@atk
Comment options

@mb21
Comment options

@cchaglund
Comment options

Answer selected by mb21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants