|
|
|
|
|
by pyrolistical
1458 days ago
|
|
I don’t understand the purpose of effect. Seems like compute can be used in all cases since you can dispose compute as well. Couldn’t read only be replaced with wrapping an observable in a closure? const $a = $observable(42) const $b = () => $a() IMO “use after dispose” should crash to make it easier to detect bugs. Also dispose should error when it texts a request to dispose something that still has a dependency. It is unlikely this is intended as it would likely lead to a “use after free” or memory leak. |
|
Not OP, but:
- You could just use computeds instead of effects, but:
> Couldn’t read only be replaced with wrapping an observable in a closure?Yes, internally it's probably just a `$computed( $observable )`. The differences are that one is just a function and the other is an observable, which is a detectable difference that may matter, but also potentially the utility function could return you always the same observable if it has already a reference to a read-only version of the one you give it, which may consume less memory (1 function to keep around rather than N), though this is a bit of an edge case.