Path syntax flexibility
Is this example from the docs supposed to work? Seems nice to be able to select keys using a function, but I can't seem to get it to work:
https://docs.solidjs.com/concepts/stores#path-syntax-flexibility
9 Replies
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
That seems incorrect, the correct synatx is:
updateUsers([1,3], 'loggedIn', false)
Might be an issue with the docsI wonder if that ever worked.
The original examples where along the lines of
and
That's a shame, it looked very useful for a moment
It still works if you do
updateUsers([1,3], 'loggedIn', false)
It is possible to select records using functions though, like e.g.
update("users", i => i.id === 42, 'loggedIn', false);
It is a bit different use case thoughYeah, i know these, thanks. Im doing a lot of JsonPatch based patching when syncing to the server, so being able to represent paths as functions seemed useful
you could use shallow merging and do :
Its still compact and works if you don't like specifying the property as a string.
I looked into how produce is implemented, and realized I don't have to even pass the key! This might break in the future, but then i hope they expose the internal function (setProperty) that makes it possible for produce.
With this I made a proxy that works exactly like the one produce uses internally, but stores a JsonPatch for each mutation
I just realized the outside updateStore doesn't do anything, so produce can update the store all by itself...