underive
does not delete the derived property unless there is a dependency defined
#805
Unanswered
dlindahl
asked this question in
Bug report
Replies: 3 comments
-
Nice catch. Thanks for reporting. Would you or anyone like to fix it? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's a new proposition, which might be controversial: #792 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Transferred to: valtiojs/derive-valtio#1 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Calling
underive
withdelete: true
does not delete the derived property value unless there is a dependency.derive
subscribes to the dependencies defined within thederive
function.underive
withdelete: true
loops through all of the dependencies.Set
to delete later.proxyObject
.The problem arises from a situation where the derived function never calls
get
(for whatever reason) which prevents a subscription from being created. The lack of a subscription prevents the property from being deleted which then prevents new calls toderive
because the property is already defined.Is this silly? Yes.
Was this hard to debug. Also yes. 😄
Property deletion should probably be decoupled from the existence of a subscription, especially since I see some async subscriptions being handled in the
derive
code which could possibly introduce a situation whereunderive
is called before the async value resolves which would result in a similar error.Link to reproduction
Pardon the lack of a codesandbox repro as the problem seemed pretty straight forward. I can make one if you really need one though.
Check List
Please do not ask questions in issues.
I've already opened a discussion before opening this issue, or already discussed in other media.Please include a minimal reproduction.
I've added a link to a typescript playground or codesandbox with a minimal reproduction.Beta Was this translation helpful? Give feedback.
All reactions