Hi, thanks for making this amazing library, it improved my code by a lot!
Just wanted to share a small annoyance I often come across:
$memo wraps its content in a callback, i.e.
$memo(33) -> createMemo(() => {return 33})
Which is great, but I also often need to do some computation, so I need a function to do it. If I put in a callback, it's going to get wrapped, which I'd argue is not a common use case.
$memo(() => 33) -> createMemo(() => () => {return 33}) (we don't want to wrap it here)
A hacky workaround:
$derefMemo(createMemo(() => {
return 33;
}));
I would argue that 99% of the time, we want to return a value rather than a callback, so I suggest changing the behavior for function parameters.
For the remaining 1% it would also be ergonomic enough IMO:
$memo(() => () => 33) (the memo value should be () => 33 here)
I didn't check the $ helper yet, but since it combines memo and effect, it's probably also affected.
Would like to hear your opinion on this!
Hi, thanks for making this amazing library, it improved my code by a lot!
Just wanted to share a small annoyance I often come across:
$memo
wraps its content in a callback, i.e.$memo(33)
->createMemo(() => {return 33})
Which is great, but I also often need to do some computation, so I need a function to do it. If I put in a callback, it's going to get wrapped, which I'd argue is not a common use case.
$memo(() => 33)
->createMemo(() => () => {return 33})
(we don't want to wrap it here)A hacky workaround:
I would argue that 99% of the time, we want to return a value rather than a callback, so I suggest changing the behavior for function parameters.
For the remaining 1% it would also be ergonomic enough IMO:
$memo(() => () => 33)
(the memo value should be() => 33
here)I didn't check the
$
helper yet, but since it combines memo and effect, it's probably also affected.Would like to hear your opinion on this!