hyperknot
hyperknot
Explore posts from servers
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
Thank you for those examples @peerreynders, I'll look into them tomorrow!
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I see, it supports infinite variety of arguments. It was just a particular case of my store, that the normal case was ('key', value) and the more advanced case was 3 params, but now I understand it could have been 3+ params as well.
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I think we thought the same, maybe with a <> b swapped, but I think I understand now the concept you were trying to explain to me.
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
or this
setStore({ from: 1, to: store.length - 1 }, "loggedIn", false)
setStore({ from: 1, to: store.length - 1 }, "loggedIn", false)
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
for example this from the docs:
setStore("users", store.users.length, {
id: 3,
username: "michael584",
location: "Nigeria",
loggedIn: false,
})
setStore("users", store.users.length, {
id: 3,
username: "michael584",
location: "Nigeria",
loggedIn: false,
})
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I don't follow that. I wanted to write 3 scenarios, where - everything is updated, that was my scenario as of yesterday - reconcile runs the diffing algorithm with deep comparison, possibly nothing is updated - the third one is similar to your [...prevState, newItem] example, resulting in a partial update for For. Or at least I tried to write these
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
and For uses this to detect needed updates
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I see! So basically:
a = [{t:1}, {t:2}]
b = [{t:1}, {t:2}]
a[0] === b[0] => False
a = [{t:1}, {t:2}]
b = [{t:1}, {t:2}]
a[0] === b[0] => False
but
a = [{t:1}, {t:2}]
b = [{t:1}, {t:2}]
... reconcile()
a[0] === b[0] => True
a = [{t:1}, {t:2}]
b = [{t:1}, {t:2}]
... reconcile()
a[0] === b[0] => True
and also
a = [{t:1}, {t:2}]
b = [a[0], {t:3}]
a[0] === b[0] => True
a = [{t:1}, {t:2}]
b = [a[0], {t:3}]
a[0] === b[0] => True
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I see, so reconcile/applyState does a deep comparison, whereas For/mapArray only does a reference identity comparison. Which basically works as long as I use setState with 3 parameters or with reconcile.
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
OK, that's clear.
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
Not exactly. I know that signals are tracked through proxies, and I guess each item of an array proxy has it's own identity. I guess <For> uses these identities of the array proxy to check if a child-component needs an update or not.
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
These are not LLM tokens, but tokens from my markdown parser, so for example a full code block is a single token. I think there won't be too many of them in a single message of a normal chat conversation. I've looked into the keyed version, but I cannot generate real keys, only derived ones. For example I could make {type: 't', content: 'c'} into an ID: "t_c". But this will result in duplicates for example simple tokens like <hr/> will be repeated. So in conclusion, reading the code, I believe the non-keyed version will be perfect for my use case. What's left to understand is the connection between <For> and the reconcile/applyState.
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I'm also reading the source code. What's interesting is that in my use case (streaming text, only the last section changes) it seems to work perfectly without supplying an id. And afaik the deep comparison happens because of the recursive nature of applyState
33 replies
SSolidJS
Created by hyperknot on 2/21/2025 in #support
Why does my component only update in a dummy For loop?
Thanks!
15 replies
SSolidJS
Created by hyperknot on 2/21/2025 in #support
Why does my component only update in a dummy For loop?
Great, thanks! So no need for createEffect or createRenderEffect for this?
15 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
I'm really happy with reconcile, basically it contains the same prefix matching algorithm which I was about to implement. It's super nice. One thing which isn't clear is it can take a key param. Is that totally optional? If my array consists of objects, does it do deep comparison if a key is not supplied?
33 replies
SSolidJS
Created by hyperknot on 2/22/2025 in #support
How to modify array partially?
Is it possible that it's as simple as using reconcile? Does it do all the magical deduplication?
setStreamingMarkdown(text: string) {
const newTokens = getMarkdownTokens(text)
this.setState('streamingMarkdownTokens', reconcile(newTokens))
}
setStreamingMarkdown(text: string) {
const newTokens = getMarkdownTokens(text)
this.setState('streamingMarkdownTokens', reconcile(newTokens))
}
But how does it work? I mean how can reconcile compare two arrays if the only parameter it has is a single array?
33 replies
SSolidJS
Created by hyperknot on 2/21/2025 in #support
Why does my component only update in a dummy For loop?
ok, inlining I get it, it works. can you explain the "You could use a normal function too" part?
15 replies
SSolidJS
Created by hyperknot on 2/21/2025 in #support
Why does my component only update in a dummy For loop?
so I just cannot use it outside of the JSX part?
15 replies
SSolidJS
Created by hyperknot on 2/21/2025 in #support
Why does my component only update in a dummy For loop?
Is there any way to say that one value is reactive, without using createMemo?
15 replies