Circular references in Stores?
Hi again, Solid community! Coming with another new person question ๐
Is it possible to have circular references in Stores?
I created a Playground which seems to indicate that it's not: https://playground.solidjs.com/anonymous/8f07d9c2-54da-43e9-8e08-88393f446bca
If not, are there any recommended alternative patterns for this kind of thing? I can think of a few options, but haven't used Solid for very long yet, so would love to hear from others!
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
17 Replies
could it be that the store's setter doesn't work like that? ๐ค circular references should be supported
it seems indeed buggy for some reason though ๐ค
it looks like a bug to me, I've reposted the repro in #reactivity ๐
Thanks! Read through #reactivity and it sounds like it's probably a bug but we're not sure why it's happening?
I think we figured it out eventually, the "unwrap" is doing something it shouldn't be doing, but I'm not sure if Ryan saw the discussions, it would be best if you could open a GitHub issue about this
Okay, will do!
Posted here: https://github.com/solidjs/solid/issues/2056 . Feel free to add any additional context you think might be helpful!
GitHub
Circular references in Stores seem to trigger loss of proxying ยท Is...
Describe the bug (From Discord support channel here with more investigation details. Was told to file here as a bug) Solid Playground: https://playground.solidjs.com/anonymous/8f3ae147-b722-4b67-85...
Also, how long does it usually take for issues like this to get a root cause? Just wondering if I should rework my code that originally ran into this issue (which was more complex than dogs and trainers), or wait
No pressure or expectation at all to be clear!
I'm really grateful for all your prompt responses, and I know most of this is community supported
I'm not sure, I don't expect issues like that to be fixed anytime soon actually, most of the focus is allocated elsewhere at the moment I think.
Thanks for opening the issue ๐
Thank you!
I assume if I get antsy, I can try to fix it myself? If so, any pointers on where to start?
It depends on what the goal is exactly, if you want a fix to be shipped in Solid the first step is getting Ryan to agree that
unwrap
is indeed buggy, then one should try to agree on what the fix should be, personally the "obvious" fix from my point of view is simply making unwrap
a constant-time operation, it just unwraps the store proxy from the input, if any, and that's it
If you want to get this fixed in your code sooner rather than later honestly the best option might be to switch to a different store implementation, the one in Solid is borderline unusable as far as I'm concerned, and a better one can be written in userlandyou can also use a class to ignore wrap/unwrap
imo, it aligns better with the pattern you're going for
what purpose would the class have other than as a workaround for this bug?
as a workaround
right
you said it aligns better with what @QWu4xYV was going for, I assumed you meant it was going to be useful for something else also
looks like avoiding classes
it just looks like exporting a Solid-style store to me ๐ค
the structure of the types and then
makePerson
looks like a constructor
more of a factory function because store needs to be constructed first
if these are combined
Thanks! It turned out to be easier than I expected to rework my code to avoid this, so that's what I did for now